Working with a Gridview Edit Template at runtime.
-
Hi all, I have a gridview that has an edit template with a textbox and a dropdown list in it. At runtime the textbox and dropdown are invisible on the gridview (because they only show in edit view). When I click "Edit", the textbox and dropdown appear. I want to be able to reference the dropdown list but when I try to do so, I get the "Object reference not set to an instance of an object." error. Here is my code: protected void grdTrak_RowDataBound1(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { ((DropDownList)e.Row.FindControl("dlStatus")).Attr ibutes.Add("onSelectedIndexChanged", "enableother(this)"); } } Does any one know what the problem could be? Thank you in advance! Dave
-
Hi all, I have a gridview that has an edit template with a textbox and a dropdown list in it. At runtime the textbox and dropdown are invisible on the gridview (because they only show in edit view). When I click "Edit", the textbox and dropdown appear. I want to be able to reference the dropdown list but when I try to do so, I get the "Object reference not set to an instance of an object." error. Here is my code: protected void grdTrak_RowDataBound1(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { ((DropDownList)e.Row.FindControl("dlStatus")).Attr ibutes.Add("onSelectedIndexChanged", "enableother(this)"); } } Does any one know what the problem could be? Thank you in advance! Dave