A user control is written, and the user control contains a DataGrid.
The columns in the DataGrid are dynamically generated (including an editcommandcolumn ). Then an editcommand event is added to the DataGrid for processing. Program. You can edit the data of the current row when you click editcommandcolumn.
Run and click editcommandcolumn. No response is returned. After tracking, the editcommand event handler was not triggered. Strange thing !!!
We thought it was the reason why the DataGrid was created dynamically. Finally, we can find out the problem of loading the user control (the Dynamically Loaded control needs to be forcibly converted ):
Original statement:
Control TMP = (page. loadcontrol ("testcontrol. ascx "));
Phldtest. Controls. Add (TMP );
Modified statement:
Testcontrol TMP = (testcontrol) page. loadcontrol ("testcontrol. ascx "));
Phldtest. Controls. Add (TMP );
Refer:
Http://p2p.wrox.com/topic.asp? Topic_id = 7114