hai to all
how to access dropdownlist in gridview and
how to edit , update that dropdownlist in gridview......?
Loading
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 attend5days leftRegister
Bhupendrakumar Tiwari9 reputationPosted Mar 4, 2012, 7:48 PM EST
in below example AssignedToId is drop down control name
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList ddlAssignedTo = (DropDownList)e.Row.FindControl("AssignedToId");
}
}
shashi reddy139 reputationPosted Mar 4, 2012, 8:36 PM EST
Jignesh TrivediRank #16 · 50.3K reputationPosted Mar 4, 2012, 10:19 PM EST
First Option : you can get the value drop down in Row Command event of Grid View.
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "cmdSave")
{
DropDownList d = (DropDownList)GridView1.Rows[1].FindControl("ddlTest");
}
}
second Option : Data retrive on single button click.
protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < gridview1.Rows.Count; i++)
{
if (gridview1.SelectedIndex == i)
{
DropDownList d = (DropDownList)gridview1.Rows[i].FindControl("ddlTest");
}
}
}
hope this help.