asp.net - Capture DropDownList Index Change event inside of grid View -


I've put a gridview inside control, trying to catch the selected index playful event for a drop down list It keeps right back, but the event handler I have not changed in the chosen index is my code here

  dropdown list myddl; Protected Zero Page_Load (Object Sender, EventAgps E) {this.myGridview.RowDataBound + = New GridViewoverViewHandler (myGridview_RowDataBound); Myddl = new DropDownList (); Myddl.SelectedIndexChanged + = New EventHeader (myddl_SelectedIndexChanged); If (! Page.IsPostBack) {list & lt; Team & gt; Teams = Meets (paid); This.myGridview.DataSource = Teams; This.myGridview.AutoGenerateColumns = false; Boundfield col1 = new boundfield (); Col1.DataField = "name"; This.myGridview.Columns.Add (col1); Boundfield col2 = new boundfield (); Col2.DataField = "Sports"; This.myGridview.Columns.Add (col2); Boundfield col3 = new boundfield (); Col3.DataField = "Status"; This.myGridview.Columns.Add (col3); This.myGridview.DataBind (); }} Zero myGridview_RowDataBound (Object Sender, GridViewRowEventArgs e) {myddl = new DropDownList (); Myddl.SelectedIndexChanged + = New EventHeader (myddl_SelectedIndexChanged); & Lt; String & gt; Item = new list & lt; String & gt; (); Items.Add ("Good"); Items.Add ("bad"); Myddl.DataSource = Items; Myddl.AutoPostBack = True; Myddl.DataBind (); E.Row.Cells [2] .Controls.Add (myddl); } Zero myddl_SelectedIndexChanged (object sender, EventArgs e) {string temp = "here"; // Newway hits this code}} Private list & lt; Team & gt; GiveMeTeams () {team teams = new teams (); Team. Add (new team ("redwings", "hockey", "good")); Team. Add (new team ("Lions", "Football", "Bad")); Teams.Add (new team ("Packers", "Football", "Good")); Return teams; }   

Any help is greatly appreciated. Thanks,

Edited on the basis of comments

I have suggested that I have tried ... and still the post is not capturing back. Here's my new code

  zero myGridview_RowCreated (Object Sender, GridViewRowEventArgs e) {DropDownList myddl = new DropDownList (); Myddl = new DropDownList (); Myddl.SelectedIndexChanged + = New EventHeader (myddl_SelectedIndexChanged); Myddl.ID = "MyID" + E. Ro Row Indexes Toasting (); E.Row.Cells [2] .Controls.Add (myddl); } Zero myGridview_RowDataBound (Object Sender, GridViewRowEventArgs e) {DropDownList myddl = E. Ro FindControl ("MyID" + e.Row.RowIndex.ToString ()) as DropDownList; //myddl.SelectedIndexChanged + = new eventHeader (myddl_SelectedIndexChanged); & Lt; String & gt; Item = new list & lt; String & gt; (); Items.Add ("Good"); Items.Add ("bad"); Myddl.DataSource = Items; Myddl.DataMember = "status"; Myddl.AutoPostBack = True; Myddl.DataBind (); E.Row.Cells [2] .Controls.Add (myddl); }   

It is not going to be in my myl_libellectedIndexChanged () eventhandler.

Create a dropdown list in the row creator of that grid and assign it an ID to the code in the dropdown in < > E.row.FindControl ("MyDropdownlistID") and force them to the data source. Always create a separate dropdown instance instead of referencing the same

Comments