Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi everyone.

I Have problem.i have a grid view in which i have put dropdown list.now i want to add the items to one of the drpdwnlist at the selected index change of other one.my problem is that i m nt getting that particular dropdownlist
at the selected index change of first dropdownlist ..can any have idea plz help i m very confused.I have Binded It .But There Is Another Problem Take a Look At The Code in Selected index Change.
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList ddl = sender as DropDownList;
string BuildingName = ddl.SelectedItem.Text;
Int32 buildid = objbuilding.slect_bid_for_floor(BuildingName);
DataSet dsss = OBJFLOOR.FloorId_Acc_Building(buildid);
// int index = Convert.ToInt32(GridView1.SelectedRow.RowIndex);
//DropDownList ddlg = (DropDownList)(GridView1.SelectedRow.FindControl("DrpFloor"));
// Control gridrow = GridView1.Rows;
GridViewRow rr = GridView1.SelectedRow;
foreach (Control gridrow in GridView1.Rows)
{
DropDownList ddlg = (DropDownList)gridrow.FindControl("DrpFloor");

ddlg.DataSource = dsss.Tables[0];
ddlg.DataTextField = "Floor_Name";
ddlg.DataValueField = "Fid";
ddlg.DataBind();
ddlg.Items.Insert(0, new ListItem("Select", "-1"));
}
// DropDownList ddlg = (DropDownList)(GridView1.FindControl("DrpFloor"));

}

Now My DropDown Is Binded But This Is Binding All The DropDowm.I Have Dyanamic Row Created In Grid View And I Want to Bind Each DropDown INdivisusally Please Let Me Know...There Are So Many Gr8 Programmer Doesn't Any one know Sol....
Posted
Updated 5-Jul-10 22:44pm
v2

1 solution

Just get parent to get the row which caused the event and then find drop down

GridViewRow gvrow = (GridViewRow)((DropDownList)(sender)).NamingContainer;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900