Hi Nerdanalysis,
Please assign your subcategoryID in the value attribute and subcategoryName in the Text attibute then you will get the corresponding subcategoryID if you select any sub category .. Please find the below sample
<asp:DropDownList ID="ColorList" AutoPostBack="True" OnSelectedIndexChanged="Selection_Change"
runat="server">
<asp:ListItem Selected="True" Value="White"> White </asp:ListItem>
<asp:ListItem Value="Silver"> Silver 1 </asp:ListItem>
<asp:ListItem Value="DarkGray"> Dark Gray 1 </asp:ListItem>
<asp:ListItem Value="Khaki"> Khaki 1</asp:ListItem>
<asp:ListItem Value="DarkKhaki"> Dark Khaki1 </asp:ListItem>
</asp:DropDownList>
If you are populating value from the data base on the OnSelectedIndexChanged event of category list then assign subcategoryName to DataTextField attribute and subcategoryID to DataValueField @ the time of binding.
<asp:DropDownList id="DropDownList1" runat="server"
DataSource="<% databindingexpression %>"
DataTextField="DataSourceField"
DataValueField="DataSourceField"
AutoPostBack="True|False"
OnSelectedIndexChanged="OnSelectedIndexChangedMethod">
Bind using code behind :
subCatList.DataTextField = "subcategoryName ";
subCatList.DataValueField = "subcategoryID";
No need to write SP for getting sub category id..
Please reply me if this helps you or you need some more clarification.
If this satisfy your requirement please mark as answer.
Thanks & Rgards,
Dhiren Kumar Kaunar
Nerdanalysis, if this helps please login to Mark As Answer. | Alert Moderator