How to bind DropDownList in GridView.

Default.aspx

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
        <Columns>
        <asp:TemplateField HeaderText="Sno">
        <ItemTemplate>
        <%# Container.DataItemIndex + 1 %>
        </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Salary">
         <ItemTemplate>
        <%#Eval("Salary"%>
        </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Address">
         <ItemTemplate>
        <%#Eval("Address"%>
        </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Deptno">
         <ItemTemplate>
        <%#Eval("Deptno"%>
        </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="EmpName">
        <ItemTemplate>
        <asp:DropDownList ID="ddl" runat="server">
        <asp:ListItem>--Select--</asp:ListItem>
        </asp:DropDownList>
        </ItemTemplate>
        </asp:TemplateField>
        </Columns>
</asp:GridView>

Default.aspx.cs

protected
void Page_Load(object sender, EventArgs e)
{
    BindGrid();
}

private
void BindGrid()
{
    SqlConnection con = new SqlConnection("");
    SqlDataAdapter da = new SqlDataAdapter("select * from emp", con);
    da.Fill(ds, "Emp");
    GridView1.DataSource = ds;
    GridView1.DataBind();
    foreach (GridViewRow grdRow in GridView1.Rows)
    {
        DropDownList drdList = new DropDownList();
        // Nested DropDownList Control reference is passed to the DrdList object. This will allow you access the properties of dropdownlist placed inside the GridView Template column.
        drdList = (DropDownList)( GridView1.Rows[ grdRow.RowIndex ].Cells[4].FindControl( "ddl" ));
        // DataBinding of nested DropDownList Control for each row of GridView Control.
        drdList.DataSource = ds;
        drdList.DataValueField = "Sno"
        drdList.DataTextField = "Name";
        drdList.DataBind();
    }
}

 

Next Recommended Reading How To Bind DropDownList In ASP.NET MVC