Hi
how to create comboboxes dynamically in datagridview
How to create comboboxes dynamically in datagridview
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Soft CornerRank #1,221 · 1.5K reputationPosted Dec 26, 2010, 9:03 PM EST
try this
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList ddlnewList = new DropDownList();
ddlnewList.DataBind();
TableCell tc = new TableCell();
tc.Controls.Add(ddlnewList);
e.Row.Cells.AddAt(0, tc);
}
}
Suthish NairRank #92 · 22.8K reputationPosted Dec 26, 2010, 10:37 PM EST
rajesh n4 reputationPosted Dec 27, 2010, 7:20 PM EST
Soft CornerRank #1,221 · 1.5K reputationPosted Dec 27, 2010, 8:04 PM EST
public Form1()
{
InitializeComponent();
DataGridViewComboBoxColumn combo = new DataGridViewComboBoxColumn();
combo.HeaderText = "UserText";
dataGridView1.Columns.Add(combo);
}