After experimenting with my dropdownlist, I discovered that if I set visible= 'false'
, the hyperlink function of the gridview stops working. My dropdownlist has three options, and each time it changes, it needs to redirect the hyperlink to different destinations:
- PASTA
- Source
- Brand
I can only receive the result when clicking the gridview hyperlink if I keep the textbox visible set to 'true'.
<asp:DropDownList ID="stock" runat="server" AutoPostBack="true" AppendDataBoundItems="true" Width="15%"/>
<asp:TextBox ID="lblstock" runat="server" Visible="false" />
The gridview hyperlink below only works if the dropdownlist doesn't change:
<asp:HyperLink runat="server" Text='<%# Eval("FOOD_NO")%>' NavigateUrl='<%# String.Format("javascript:openWindow(""../FOOD/FOOD_STG.aspx?FOOD_NO={0}"")", Eval("FOOD_NO"))%>' />
<asp:Label ID="FOOD_NO" runat="server" Visible="False" Text='<%# Bind("FOOD_NO") %>' />
JavaScript:
function openWindow() {
var result = document.getElementById("lblstock").value.strURL;
var url = "";
if (result != "")
{
switch (result) {
case "PASTA":
url = "../FOOD_Rep/FOOD_Rep.aspx?FOOD_NO={0}";
break;
case "Source":
url = "../FOOD_Ing/FOOD_Ing.aspx?FOOD_NO={0}";
break;
case "Brand":
url = "../FOOD_Brd/FOOD_Brd.aspx?FOOD_NO={0}";
break;
}
var winopen = window.open(url + "&FOOD_ID=" + $("#GROUP_ID").val(), 'Memo', ' left=50, screenx= 10, width=1360,height=820,scrollbars=1,resizable=1,toolbar=0');
winopen.focus();
}
Vb code behind:
lblstock.Text = stock.SelectedValue
I have been facing this issue for some time now, any help would be greatly appreciated. Thank you.