This is mainly a tip for beginners, and those looking at the DataList as an option. Its primary benefit is its nearly unlimited formatting capabilites --
In this example there is a DropDownList and a DataList. In the DataList, among various objects, is a linkbutton which functions to redirect the page based on the selected value in the nearby DropDownList.
Within the DataList structure the linkbutton as:
<asp:linkbutton
id="lnkSite"
runat=server
Forecolor="red"
Font-bold="true"
CommandArgument=<%# Container.DataItem("AwwSiteCode"
%>
OnCommand=commandHandler>
<%# Container.DataItem("AwwSiteCode"
%>
</asp:linkbutton>
The OnCommand event is:
Protected Sub commandhandler(sender As Object, e As CommandEventArgs)
If ddChart.SelectedItem.Text = "Chemistry Histories" Then
Response.Redirect("ddChemHistory.aspx?AwwSiteCode=" & e.CommandArgument)
ElseIf ddChart.SelectedItem.Text = "Chemistry Real Time" Then
Response.Redirect("ChemRT.aspx?AwwSiteCode=" & e.CommandArgument)
ElseIf ddChart.SelectedItem.Text = "Bacteria Histories" Then
Response.Redirect("ddBacHistory.aspx?AwwSiteCode=" & e.CommandArgument)
Else
Response.Redirect("BacRT.aspx?AwwSiteCode=" & e.CommandArgument)
End If
End Sub
Where the "e.CommandArgument" completes the QueryString and the page is then properly redirected.
fyi
In this example there is a DropDownList and a DataList. In the DataList, among various objects, is a linkbutton which functions to redirect the page based on the selected value in the nearby DropDownList.
Within the DataList structure the linkbutton as:
<asp:linkbutton
id="lnkSite"
runat=server
Forecolor="red"
Font-bold="true"
CommandArgument=<%# Container.DataItem("AwwSiteCode"
OnCommand=commandHandler>
<%# Container.DataItem("AwwSiteCode"
</asp:linkbutton>
The OnCommand event is:
Protected Sub commandhandler(sender As Object, e As CommandEventArgs)
If ddChart.SelectedItem.Text = "Chemistry Histories" Then
Response.Redirect("ddChemHistory.aspx?AwwSiteCode=" & e.CommandArgument)
ElseIf ddChart.SelectedItem.Text = "Chemistry Real Time" Then
Response.Redirect("ChemRT.aspx?AwwSiteCode=" & e.CommandArgument)
ElseIf ddChart.SelectedItem.Text = "Bacteria Histories" Then
Response.Redirect("ddBacHistory.aspx?AwwSiteCode=" & e.CommandArgument)
Else
Response.Redirect("BacRT.aspx?AwwSiteCode=" & e.CommandArgument)
End If
End Sub
Where the "e.CommandArgument" completes the QueryString and the page is then properly redirected.
fyi