Event handler of Dropdownlist inside Gridview
Posted
by hotcoder
on Stack Overflow
See other posts from Stack Overflow
or by hotcoder
Published on 2010-01-06T04:58:11Z
Indexed on
2010/05/10
6:54 UTC
Read the original article
Hit count: 398
I've added Dropdownlist in Gridview at RowDataBound event. The code is:
if (e.Row.RowType == DataControlRowType.DataRow) { DropDownList ddlSeason = new DropDownList();
ddlSeason.DataSourceID = "odsRoomSeason"; ddlSeason.DataTextField = "SeasonTittle"; ddlSeason.DataValueField = "SeasonID"; ddlSeason.AutoPostBack = true; ddlSeason.SelectedIndexChanged += new EventHandler(ddlSeason_SelectedIndexChanged);
TableCell tcSeason= new TableCell();
tcSeason.Controls.Add(ddlSeason); e.Row.Cells.AddAt(e.Row.Cells.Count, tcSeason); }
The event handler I've added is: protected void ddlSeason_SelectedIndexChanged(object sender, EventArgs e) { // }
But the problem is that the event handler function doesn't catch the event. Please tell me how to write the correct event handler, also I need to get the row from which the Dropdownlist's event has fired.
© Stack Overflow or respective owner