Well do some thing like follow:
Only problem i think would be is performance degrade, isn't? anyone has some solution?
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="EmpId" DataSourceID="SqlDataSource1"
ondatabound="GridView1_DataBound">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="EmpId" HeaderText="EmpId" ReadOnly="True"
SortExpression="EmpId" />
<asp:BoundField HeaderText="Category" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>"
SelectCommand="SELECT * FROM [employee]"></asp:SqlDataSource>
protected void Page_Load(object sender, EventArgs e)
{
if(IsPostBack)
addControl();
}
void addControl()
{
foreach (GridViewRow row in GridView1.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
DropDownList dl = new DropDownList();
dl.Items.Add("One");
dl.Items.Add("Two");
row.Cells[2].Controls.Add(dl);
}
}
}
protected void GridView1_DataBound(object sender, EventArgs e)
{
addControl();
}