Home » Applications » GridView drop-down list record update:

GridView drop-down list record update:

Found this code on msdn library and use it all the time. Code is pretty straight forward and easy to implement and customizable. Have fun using it.

<asp:TemplateField SortExpression="CategoryName" 
HeaderText="CategoryName">
   <EditItemTemplate>
        <asp:DropDownList ID="DropDownList1" Runat="server" 
          DataSourceID="categoryDataSource"
            DataTextField="CategoryName" DataValueField="CategoryID" 
            SelectedValue='<%# Bind("CategoryID") %>'>
        </asp:DropDownList>        
   </EditItemTemplate>
   <ItemTemplate>
       <asp:Label Runat="server" Text='<%# Bind("CategoryName") %>' 
          ID="Label1"></asp:Label>
   </ItemTemplate>
</asp:TemplateField>

For more related code read here…