DropDown inside gridview

Discussion in '.NET' started by sheraz_aries, Jun 9, 2010.

  1. sheraz_aries

    sheraz_aries

    Joined:
    Feb 25, 2008
    Messages:
    5
    Now the dropdown displaying the current value from my db but how do i update the selected value so that it save in database.

    Code:
    # Protected Sub GV_ApproveNomination_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GV_ApproveNomination.RowDataBound  
       
       
         If e.Row.RowType = DataControlRowType.DataRow Then  
             Dim cmbGender As DropDownList = CType(e.Row.FindControl("DdlGender"), DropDownList)  
       
             cmbGender.SelectedValue = GV_ApproveNomination.DataKeys(e.Row.RowIndex).Values(1).ToString()  
             cmbGender.DataBind()  
       
         End If  
     End Sub 

    Code:
     <asp:TemplateField HeaderText="Gender">  
         <ItemTemplate>  
             <asp:Label ID="lblGender" runat="server" Text='<%# Eval("iGender") %>'></asp:Label>  
         </ItemTemplate>  
       
         <EditItemTemplate>  
           
          <asp:DropDownList ID="DdlGender" runat="server" SelectedValue='<%# Trim(Eval("iGender"))%>'>  
                 <asp:ListItem Value="M" Text="Male"></asp:ListItem>  
                 <asp:ListItem Value="F" Text="Female"></asp:ListItem>  
         </asp:DropDownList>  
           
               
         </EditItemTemplate>  
     </asp:TemplateField> 
     
    sheraz_aries, Jun 9, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vishnu
    Replies:
    1
    Views:
    1,230
    Patrick.O.Ige
    Mar 25, 2006
  2. Mike
    Replies:
    1
    Views:
    824
  3. HockeyFan
    Replies:
    1
    Views:
    1,010
    Masudur
    Jul 4, 2007
  4. anonymoushamster@gmail.com
    Replies:
    2
    Views:
    446
    anonymoushamster@gmail.com
    Nov 7, 2007
  5. Babu

    Dropdown Inside Gridview SelectedIndexChange Event

    Babu, Dec 12, 2007, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    943
    John Padilla
    Dec 15, 2007
Loading...

Share This Page