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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Mar 5, 2012, 3:19 AM
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.
shashi reddyPosted Mar 5, 2012, 1:36 AM
Bhupendrakumar TiwariPosted Mar 5, 2012, 12:48 AM
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");
}
}