How can we handle the onselectedindexchanged event of a dropdownlist in a gridview/datalist?
-
29-10-2019 - |
Question
I have a simple datalist with a dropdownlist and a textbox.
When the dropdownlist selected index changes, I want to load a value into the textbox in that listbox item (i.e., the textbox on that particular row).
<ItemTemplate>
<asp:DropDownList runat="server"
ID="ddlCategory" AutoPostBack="true"
DataTextField="category"
DataValueField="category_code"
OnSelectedIndexChanged="ddlCategory_SelectedIndexChanged" />
<br />
Code<asp:TextBox
runat="server"
ID="txtOutputCode"
Text='<%# Bind("output_code") %>' />
</ItemTemplate>
How do I do this?
The challenge I'm facing is how to find the corresponding textbox to update.
E.g. for a button I'd pass a commandname, and command arguments. And then I'd handle the event in the gridview or datalist to find the corresponding textbox and update the text. What can we do in case of a selectedindex change of a dropdownlist?
Thanks!
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow