ASP.Net GridView Template DropDownList
GridView TemplateField allows you to add ASP.Net server controls inside its ItemTemplate. You can place the DropDownList inside the ItemTemplate of GridView control to display the items stored in the tbl_order_status table of SQL database that we discussed in the previous article about ASP.Net GridView DropDownList. You can use the following HTML code in ASP.Net web page to display the order_id in the first Template field and DropDownList in the second template field of GridView control columns.
GridView Examples:
You can see the live samples and examples of GridView from the following links:
HTML Code for DropDownList inside GridView Control
<asp:GridView ID="GridView1"
runat="server"
AutoGenerateColumns="false"
BorderStyle="Solid"
CellPadding="4"
DataKeyNames="order_id,order_status_id"
BorderColor="Silver"
BorderWidth="1px"
Width="300px">
<Columns>
<asp:TemplateField HeaderText="OrderID">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "order_id") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Order Status">
<ItemTemplate>
<asp:DropDownList ID="DropDownList1"
runat="server">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle HorizontalAlign="Left" />
</asp:GridView>
In the above code for GridView Control with DropDownList, DataKeyNames property of GridView is used to store the order_id and order_status _id for each record retrieved and displayed in the rows of GridView control. Order_status_id stored in the DataKeyNames collection of GridView enables you to set the SelectedValue property of DropDownList retrieved from tbl_orders table. But before assigning the value to SelectedValue property of DropDownList placed inside the GridView control you have to bind the data with Gridview control as well as predefined list items in tbl_order_status table with DropDownList. For Data Binding steps you can start with Data binding with GridView control. After GridView Databinding you will get the order_status_id in the form DataKeyNames collection values that you can use to set the SelectedValue property of DropDownList placed in the GridView to display the order status od any particular order.
Continue to next tutorial: ASP.Net GridView DropDownList DataSource and DataBinding to learn how to bind the data to dropdownlist control placed inside the gridivew control.

* will not be published
* hint: http://www.example.com