By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,666 Members | 1,784 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,666 IT Pros & Developers. It's quick & easy.

How to fix something on a web page

P: n/a
I'm wanting to fix the following on a web page without really re-inventing
anything.

What I have is a vb web page with a radiobuttonlist where I can pick Current
or History year.

Underneath that is a listbox that has a set of reports in it, some for
current year, some for history year. If Current year is chosen, 6 reports
(depending on user access level) are listed, on the History one, 2 are
listed (also depending on user access level). The menus are developed as a
part of the page_load event (see below).

What happens is that the list gets built when the page opens, and items are
listed and removed, based on their access level. The selectedindex property
is set to -1 when the page is initally displayed (the radio button and the
listbox are set to autopostback).

The problem is, if I click on the History radio button, and then 1 of the
reports, it does nothing, other than post back to the page. At that time,
the selected index is still -1 (when I click on the report on the history
tab the first time). When I click on it a second time, it sets it to the
appropriate value and runs the report.

There is code in the selectedindexchanged event that checks to see if the
index is set to -1, it exited the sub, and on the autopostback, I'd click it
a second time to run the report.

I'm not sure what to do with this piece of code, to just display a menu of
reports to run.

I would appreciate any input as to a "good" way (this one seems bassackwards
to me) to make a list of reports to programatically display to sets of
users, passing on appropriate session variables.

Any help appreciated.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
' Session("Connectstring") = Application("Connectstring")
rbtnSales.Visible = False
If Request.QueryString("User") = "" Then
lblUser.Text = Session("UserName")
End If
If Session("Sales") = "" Then
Session("Permission") = Request.QueryString("P")
Session("Pass") = Request.QueryString("Pass")
Session("UserName") = Request.QueryString("Name")
Session("ActUser") = Request.QueryString("Act")
Session("User") = Request.QueryString("User")
Session("Sales") = Request.QueryString("Sales")
Session("Calendar") = Request.QueryString("Calendar")
Session("Sales") = Session("Sales").replace("-", "/")
Session("Sales") = Session("Sales").replace(".", ":")
Session("Calendar") = Session("Calendar").replace("-", "/")
Session("Calendar") = Session("Calendar").replace(".", ":")
Session("ViewProdHierSKUStatus") =
Request.QueryString("SKUStat")
Session("ViewOldSys") = Request.QueryString("Oldsys")
End If

If Session("UserName") = "" Then
Server.Transfer("../Default.aspx")
End If
Session("ActUser") = UCase(Session("ActUser"))

btnNewJreports.Visible = True
If rbtnRpts.SelectedItem.Value <> Type Then
ListBox2.Visible = False
If rbtnRpts.SelectedItem.Value = "CY" Then
ListBox1.Items.Clear()
ListBox1.Items.Add("Purchase Order Status")
ListBox1.SelectedIndex = 0
ListBox1.SelectedItem.Value = "CYPOS"
ListBox1.Items.Add("Product Hierarchy (Business Area)")
ListBox1.SelectedIndex = 1
ListBox1.SelectedItem.Value = "CYPH"
ListBox1.Items.Add("Sales Summary")
ListBox1.SelectedIndex = 2
ListBox1.SelectedItem.Value = "CYSS"
ListBox1.Items.Add("Accessories Stock-on-Hand Report")
ListBox1.SelectedIndex = 3
ListBox1.SelectedItem.Value = "ACCSOH"
ListBox1.Items.Add("Customer Listing (J1)")
ListBox1.SelectedIndex = 4
ListBox1.SelectedItem.Value = "CLIST"
ListBox1.Items.Add("Product Listing")
ListBox1.SelectedIndex = 5
ListBox1.SelectedItem.Value = "PLIST"
'ListBox1.Rows = 11
If Session("User") = "user2" Or Session("User") = "user1" Or
Session("User") = "user3" Or Session("User") = "user4" Or Session("User") =
"user5" Or Session("User") = "user6" Then
ListBox1.Items.Add("Distribution Channel (Product
Hierarchy) ")
ListBox1.SelectedIndex = 6
ListBox1.SelectedItem.Value = "CYPHDC"
ListBox1.Items.Add("Distribution Channel (Customer) ")
ListBox1.SelectedIndex = 7
ListBox1.SelectedItem.Value = "CYCUSDC"
'''ListBox1.Items.Add("Summary Reports")
'''ListBox1.SelectedIndex = 8
'''ListBox1.SelectedItem.Value = "Reports"
ListBox1.Items.Add("Remlink Usage Statistics")
ListBox1.SelectedIndex = 8
ListBox1.SelectedItem.Value = "RUS"
ListBox1.Rows = 9
If Session("ViewProdHierSKUStatus") = "YES" Then
ListBox1.Items.Add("Product Hierarchy SKU Status
(Business Area)")
ListBox1.SelectedIndex = 9
ListBox1.SelectedItem.Value = "PHPO"
ListBox1.Rows = 10
End If
Else
'''' comment out these lines & change indexes to release
without J1 code.
'''ListBox1.Items.Add("Summary Reports")
'''ListBox1.SelectedIndex = 6
'''ListBox1.SelectedItem.Value = "Reports"
'''ListBox1.Rows = 7
'code for new report
If Session("ViewProdHierSKUStatus") = "YES" Then
ListBox1.Items.Add("Product Hierarchy SKU Status
(Business Area)")
ListBox1.SelectedIndex = 6
ListBox1.SelectedItem.Value = "PHPO"
ListBox1.Rows = 7
End If
End If
ListBox1.SelectedIndex = -1
Else
If Session("User") = "user2" Or Session("User") = "user1" Or
Session("User") = "user3" Or Session("User") = "user4" Or Session("User") =
"user5" Or Session("User") = "user6" Or Session("User") = "HYLERKS" Then
ListBox1.Items.Clear()
ListBox1.Items.Add("Product Hierarchy")
ListBox1.SelectedIndex = 0
ListBox1.SelectedItem.Value = "HYPH"
ListBox1.Items.Add("Customer Rank")
ListBox1.SelectedIndex = 1
ListBox1.SelectedItem.Value = "CYCR"
ListBox1.Items.Add("Item Rank")
ListBox1.SelectedIndex = 2
ListBox1.SelectedItem.Value = "HYIR"
'ListBox1.Items.Add("Quarterly")
'ListBox1.SelectedIndex = 3
'ListBox1.SelectedItem.Value = "HQPH"
ListBox1.Rows = 3
'ListBox1.Height = Unit.Pixel(55)
ListBox1.SelectedIndex = -1
Else
ListBox1.Items.Clear()
'ListBox1.Items.Add("Product Hierarchy")
'ListBox1.SelectedIndex = 0
'ListBox1.SelectedItem.Value = "HYPH"
ListBox1.Items.Add("Customer Rank")
ListBox1.SelectedIndex = 0
ListBox1.SelectedItem.Value = "CYCR"
ListBox1.Items.Add("Item Rank")
ListBox1.SelectedIndex = 1
ListBox1.SelectedItem.Value = "HYIR"
'ListBox1.Items.Add("Quarterly")
'ListBox1.SelectedIndex = 3
'ListBox1.SelectedItem.Value = "HQPH"
ListBox1.Rows = 2
ListBox1.SelectedIndex = -1
End If
End If
Type = rbtnRpts.SelectedItem.Value
End If
If Session("User") = "customer1" Or Session("User") = "customer2" Or
Session("User") = "customer3" Or Session("user") = "customer4" Or
Session("User") = "customer5" Then
BtnJReports.Visible = False
Hyperlink1.Visible = False
Hyperlink2.Visible = False
If rbtnRpts.SelectedItem.Value = "CY" Then
'If ListBox1.Items.Count = 5 Then
If ListBox1.Items.Count = 4 Then ' changed 4/2/03
items.count = 4
ListBox1.Items.RemoveAt(2)
ListBox1.Items.RemoveAt(2)
End If
If ListBox1.Items.Count = 5 Then ' changed 4/2/03
items.count = 5
ListBox1.Items.RemoveAt(4)
ListBox1.Items.RemoveAt(2)
End If
If ListBox1.Items.Count = 6 Then ' changed 4/2/03
items.count = 5
ListBox1.Items.RemoveAt(5)
ListBox1.Items.RemoveAt(4)
ListBox1.Items.RemoveAt(2)
End If
' if we have the product list showing, remove it for
customers
If ListBox1.Items.Count = 7 Then ' changed 4/2/03
items.count = 5
ListBox1.Items.RemoveAt(6)
ListBox1.Items.RemoveAt(5)
ListBox1.Items.RemoveAt(4)
ListBox1.Items.RemoveAt(2)
End If
ListBox1.Rows = 3
End If
If rbtnRpts.SelectedItem.Value = "Hist" Then
If ListBox1.Items.Count = 3 Then
ListBox1.Items.RemoveAt(0)
End If
ListBox1.Rows = 2
End If
End If

ListBox1.Rows = ListBox1.Items.Count

lblUser.Text = Session("UserName") & " Date/Time: " & DateTime.Now
'rbtnSales.Text = "Sales Year Data (" & Session("Sales") & ")
<-For Reference Only"
rbtnCalendar.Text = "Calendar Year Data (" &
Session("Calendar") & ")"
End Sub

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim sType As String
' If rbtnSales.Checked = True Then
' sType = "Sales"
' Else
sType = "Calendar"
' End If
Dim xxxx As Integer
xxxx = ListBox1.SelectedIndex
Dim yyyy As String
yyyy = ListBox1.SelectedItem.Value
'If ListBox1.SelectedIndex = -1 Then Exit Sub
Session("Report") = ListBox1.SelectedItem.Value
TransactionLog("")
Select Case ListBox1.SelectedItem.Value
Case "CYPH" 'Current Year Product Hierarchy
Server.Transfer("../sales/J5group.aspx?YR=" & sType & "&DC="
& Request("cboChannel") & "&T=" & Request("txtTerritory") & "&R=" &
Request("cboRegion") & "&BA=" & Request("BA") & "&C=Rounds" & "&UID=" &
Session("User") & "&Special=")
Case "Reports" 'Current Year Product Hierarchy
ListBox2.Visible = True
Case "CYPHC" 'Current Year Product Hierarchy Customer
Server.Transfer("../sales/customerp.aspx?DC=" &
Session("EndUse") & "&User=" & Session("User") & "&C=" & "&Yr=" & sType &
"&Special=")
Case "CYPHCI" 'Current Year Product Hierarchy Item
Server.Transfer("../sales/Item.aspx?SKU=" & "&Special=")
Case "CYPHDC" 'Current year Product Hierarchy Dist Chnl
Server.Transfer("../sales/J5group.aspx?DC=---" & "&Rpt=J4" &
"&Yr=" & sType) '& Request.QueryString("UID") & "&C=" & "&Yr=" & sType &
"&Special=")
'Server.Transfer("../sales/customerp.aspx?DC=" &
CStr(cmbChannel.SelectedItem.Value).Replace("'", "''") & "&User=" &
Request.QueryString("UID") & "&C=" & "&Yr=" & sType & "&Special=" )
'Server.Transfer("../sales/testing.aspx?User=" &
Request.QueryString("UID") & "&C=" & "&Yr=" & sType & "&Special=" )
Case "CYSS" 'Current Year Sales Summary
Server.Transfer("../sales/j4Group.aspx?DC=" &
Request("cboChannel") & "&Yr=" & sType & "&UID=" & Session("user") &
"&Special=")
' uncomment to test system page for migrating the changes
'
Server.Transfer("../sales/Holdpage-j4groupdotaspx.aspx?DC=" &
Request("cboChannel") & "&Yr=" & sType & "&UID=" & Session("user") &
"&Special=")
Case "CYCR" ' Current Year Customer Rank
Server.Transfer("../sales/pctofsales.aspx?YR=" & sType &
"&UID=" & Session("User") & "&Special=")
Case "HYPH" 'History Product Hierarchy
Server.Transfer("../sales/J7ProductHierarchy.aspx?YR=" &
sType & "&DC=" & Request("cboChannel") & "&T=" & Request("txtTerritory") &
"&R=" & Request("cboRegion") & "&BA=" & Request("BA") & "&C=Rounds" &
"&UID=" & Session("User") & "&Special=")
Case "HYPHC" 'History Product Hierarchy Customer
Server.Transfer("../sales/J7ProductHierarchy.aspx?YR=" &
sType & "&DC=" & Request("cboChannel") & "&T=" & Request("txtTerritory") &
"&Cust=" & "&R=" & Request("cboRegion") & "&BA=" & Request("BA") &
"&C=Rounds" & "&UID=" & Session("User") & "&Special=") '&
Session("user"))
Case "HYPHI" 'History Product Hierarchy Item
Server.Transfer("../sales/ItemHistory.aspx?SKU=" & "&YR=" &
sType & "&Special=")
Case "HYPHDC" 'History Product Hierarchy Dist Chnl

Case "HQPH" 'History Product Hierarchy
Server.Transfer("../sales/qtrly.aspx?YR=" & sType & "&DC=" &
Request("cboChannel") & "&T=" & Request("txtTerritory") & "&Cust=" & "&R=" &
Request("cboRegion") & "&BA=" & Request("BA") & "&C=Rounds" & "&UID=" &
Session("User") & "&Special=") '& Session("user"))
Case "HQPHC" 'History Product Hierarchy Customer
Server.Transfer("../sales/qtrly.aspx?YR=" & sType & "&DC=" &
Request("cboChannel") & "&T=" & Request("txtTerritory") & "&Cust=" & "&R=" &
Request("cboRegion") & "&BA=" & Request("BA") & "&C=Rounds" & "&UID=" &
Session("User") & "&Special=") '& Session("user"))
Case "HYQI" 'History Product Hierarchy Item
Server.Transfer("../sales/ItemQtrly.aspx?SKU=" & "&YR=" &
sType & "&Special=")
Case "HQPHDC" 'History Product Hierarchy Dist Chnl
Case "CYPOS" 'Current year Product Hierarchy Purchase Order
Status
Server.Transfer("../sales/POInquiry.aspx?DC=" & "&User=" &
Request.QueryString("UID") & "&C=" & "&Yr=" & sType & "&Special=")
Case "HYIR"
Server.Transfer("../sales/ItemRank.aspx?YR=" & sType &
"&UID=" & Session("User") & "&Special=")
Case "CYCUSDC"
Server.Transfer("../sales/POInquiryDC.aspx?DC=---" &
"&User=" & Request.QueryString("UID") & "&C=" & "&Yr=" & sType &
"&Special=")
Case "RUS"
Server.Transfer("../UserLogIns.aspx")
Case "OLD"
Server.Transfer("../sales/oldsystem.aspx?YR=" & sType)
Case "ACCSOH"
Server.Transfer("../sales/accsoh.aspx")
Case "CLIST"
Server.Transfer("../sales/customerlist.aspx?YR=" & sType)
Case "PLIST"
Server.Transfer("../sales/productlist.aspx")
Case "PHPO"
Server.Transfer("../sales/PHPOSum.aspx")
End Select

End Sub
Nov 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.