Aravind Ranganathan
asked on
DropDown list selected item always selecting the first item on the list when when i change it to update to another value.
trying to get the value of dropdown list inside a gridview in griview's update event but the value of the dropdown keeps getting set to the first value in the dropdown list, i have enabled view state and placed the binding code in (!ISPostBack) but none of that solved my problem.
so i chage the dropdownlist to bag type and click on save button which fires the update and it reverts it back to candy type i am not sure why it does that. please help
Thanks
<asp:TemplateField HeaderText ="Family Type">
<HeaderTemplate>
<asp:Label ID ="familytype" Text="Family Type" runat="server" ForeColor="White" />
<br />
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
<asp:ListItem Text="Candy Type" Value="1"></asp:ListItem>
<asp:ListItem Text="Pack Type" Value="2"></asp:ListItem>
<asp:ListItem Text="Wrap Type" Value="3"></asp:ListItem>
<asp:ListItem Text="Bag Type" Value="4"></asp:ListItem>
<asp:ListItem Text="None" Value="5"></asp:ListItem>
</asp:DropDownList>
<br />
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="familytypeCode" runat="server" Text='<%# Eval("[Family Type]") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="DropDownList3" runat="server" EnableViewState="true" AppendDataBoundItems="true" SelectedValue='<%# Bind("[Family Type]") %>'>
<asp:ListItem Text="Candy Type" Value=""></asp:ListItem>
<asp:ListItem Text="Pack Type" Value=""></asp:ListItem>
<asp:ListItem Text="Wrap Type" Value=""></asp:ListItem>
<asp:ListItem Text="Bag Type" Value=""></asp:ListItem>
<asp:ListItem Text="None" Value=""></asp:ListItem>
</asp:DropDownList>
<%-- <asp:TextBox ID = "txtfamilytype" Text = '<%# Eval("[Family Type]") %>' runat ="server" />--%>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID = "familytypefooter" runat ="server" />
</FooterTemplate>
</asp:TemplateField>
so i chage the dropdownlist to bag type and click on save button which fires the update and it reverts it back to candy type i am not sure why it does that. please help
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the answers but i just had to pass and empty string into the dropdownlist as the default value because some of the row data bound items had a empty value so it was acting up funny.
ASKER
Thanks Camila
then find the control within that row.