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.
 <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>

Open in new window



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
Aravind RanganathanWindows Application DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CamilliaCommented:
Do you have RowDataBound event? I think !(IsPostBack) should go there ... where you're doing databinding.

I can check my Web Forms code tomorrow (I turned off my laptop) if you still haven't figured it out.

This might help too possible solution
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Robberbaron (robr)Commented:
it will be the RowEditting or RowUpdating event that is triggered.

then find the control within that row.
0
Aravind RanganathanWindows Application DeveloperAuthor Commented:
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.
0
Aravind RanganathanWindows Application DeveloperAuthor Commented:
Thanks Camila
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
DropdownList

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.