M
Master ß ????
Guest
I have a GridView on a page, and each row has a DropDownList control with two entries, let's say "Alpha" and "Beta". In Edit mode, the DropDownList is the active control, but there is a Label control active to show the selected value when not editing.
Here's how the .aspx looks for each row in the GridView:
<asp:TemplateField HeaderText="Rate Type">
<ItemTemplate>
<asp:Label ID="myLabel" Text='<%# Eval("BlendRateType") %>' runat="server" />
</ItemTemplate>
<EditItemTemplate>
<asp
ropDownList id="myDropDownList" runat="server" AutoPostBack="True" OnSelectedIndexChanged="myDropDown_SelectedIndexChanged" />
</EditItemTemplate>
</asp:TemplateField>
Each row of the GridView has an Edit button. The problem is, if I click Edit on a row which has a selection in the DropDownList, that selection is not the chosen one.
In other words, say I click Edit on a row and Save the row with "Beta" in the DropDownList, which is the 2nd entry in the list (alphabetical order). This value gets saved, and then the Label displays it, which is fine.
If I click Edit again, however, the DropDownList selection is always "Alpha".
How do I ensure that when the row enters Edit mode, that it *always* grabs the value present in the Label for that row, rather than just selecting the first item in the DropDownList by default?
Here's how the .aspx looks for each row in the GridView:
<asp:TemplateField HeaderText="Rate Type">
<ItemTemplate>
<asp:Label ID="myLabel" Text='<%# Eval("BlendRateType") %>' runat="server" />
</ItemTemplate>
<EditItemTemplate>
<asp

</EditItemTemplate>
</asp:TemplateField>
Each row of the GridView has an Edit button. The problem is, if I click Edit on a row which has a selection in the DropDownList, that selection is not the chosen one.
In other words, say I click Edit on a row and Save the row with "Beta" in the DropDownList, which is the 2nd entry in the list (alphabetical order). This value gets saved, and then the Label displays it, which is fine.
If I click Edit again, however, the DropDownList selection is always "Alpha".
How do I ensure that when the row enters Edit mode, that it *always* grabs the value present in the Label for that row, rather than just selecting the first item in the DropDownList by default?