gtjr921
Programmer
- Aug 30, 2006
- 115
ASP.Net 2.0
I have a asp menu control that has dynamic links depending on the value of the EMPID
For instance if a employee record also has a 'HID'
then the menu would be something like
Health and the navigate url value would be like health.aspx?empid=509 i also change the text value depending
on if the employee has the 'HID' so in this instance the text would be health. If there was not a HID then the text would be Add Health.
The text changing according to the HID works fine.
However for some reason the EMPID/Qstring value will not change on the menu. For instance if i change my selected value everything changes to reflect the different employee id except the (0) value in my menu.
My temp labels lbl98 & lbl99 changes to show the correct id but the naviagateurl {0}value does not
For instance i get employee id 509 then i change to employee id 1234, the link in the menu still shows id 509, the text of the url changes, but not the id. See my code below
FYI there is no datasource for this menu it is static in my asp. See my code i hope that explains more.
Thanks
.Net 2 Code
VB
I have a asp menu control that has dynamic links depending on the value of the EMPID
For instance if a employee record also has a 'HID'
then the menu would be something like
Health and the navigate url value would be like health.aspx?empid=509 i also change the text value depending
on if the employee has the 'HID' so in this instance the text would be health. If there was not a HID then the text would be Add Health.
The text changing according to the HID works fine.
However for some reason the EMPID/Qstring value will not change on the menu. For instance if i change my selected value everything changes to reflect the different employee id except the (0) value in my menu.
My temp labels lbl98 & lbl99 changes to show the correct id but the naviagateurl {0}value does not
For instance i get employee id 509 then i change to employee id 1234, the link in the menu still shows id 509, the text of the url changes, but not the id. See my code below
FYI there is no datasource for this menu it is static in my asp. See my code i hope that explains more.
Thanks
.Net 2 Code
Code:
<asp:Menu ID="Menu1" runat="server" Orientation="Horizontal"
<StaticMenuItemStyle Font-Size="Small" />
<DynamicItemTemplate>
<%# Eval("Text") %>
</DynamicItemTemplate>
<Items>
<asp:MenuItem NavigateUrl="~/empdetail.aspx" Text="Home/Search" Value="Home/Search">
</asp:MenuItem>
<asp:MenuItem NavigateUrl="~/HealthDetails.aspx{0}" Text="Health" Value="Health"></asp:MenuItem>
<asp:MenuItem NavigateUrl="~/empDental.aspx{0}" Text="Dental" Value="Dental"></asp:MenuItem>
<asp:MenuItem NavigateUrl="~/EmpVision.aspx{0}" Text="Vision" Value="Vision"></asp:MenuItem>
<asp:MenuItem NavigateUrl="~/Aflac.aspx{0}" Text="Aflac" Value="Aflac"></asp:MenuItem>
<asp:MenuItem Text="Dependents" Value="Dependents" NavigateUrl="~/Depend.aspx{0}"></asp:MenuItem>
<asp:MenuItem NavigateUrl="~/empadd.aspx" Text="Add New Employee" Value="Add New Employee">
</asp:MenuItem>
</Items>
</asp:Menu>
VB
Code:
Protected Sub FviewBind(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.DataBound
Dim FVI As FormView = FormView1
If FormView1.DataItemCount > 0 Then
'Find the Employee ID
Dim qstring As String = CType(FVI.FindControl("lblEmpID"), Label).Text
Dim qstringNEW As String = CType(FVI.FindControl("lblEmpID"), Label).Text + "&Action=NEW"
'Find health id
Dim HID As String = CType(FVI.FindControl("lblHIDadd"), Label).Text
'temp labels to make sure the empid is being read 'properly
lbl98.Text = qstringNEW
lbl99.Text = qstring
'find out if this employee also has a HID
If HID = "" Then
'append the qstring value to the URL
Menu1.Items.Item(1).NavigateUrl = String.Format(Menu1.Items.Item(1).NavigateUrl.ToString(), "?EmpID=" + qstringNEW)
Menu1.Items.Item(1).Text = "Add Health"
Else
Menu1.Items.Item(1).NavigateUrl = String.Format(Menu1.Items.Item(1).NavigateUrl.ToString(), "?EmpID=" + qstring)
End If