You can use the following statement to locate the gridview command event:
Gridviewrow=(Control) E. commandsource). bindingcontainerAsGridviewrow;
You can use the following statement to find the control event in the gridview:
Gridviewrow=(SenderAsTextbox). Parent. ParentAs
Gridviewrow;
String Itemno = (Textbox) (gridviewrow. findcontrol ( " Textboxpartnonew " ). Text. Trim ();
How can I find it in page_load?
The following information from: http://www.itzhe.cn/html/web/ASP.NET/20071127/22928_2.html
Problems encountered when using the gridview to implement the insert Function
// Create a new header row
Gridviewrow headerrow = Base . Createrow ( - 1 , - 1 , Datacontrolrowtype. header, datacontrolrowstate. Normal );
This . Initializerow (headerrow, fields );
//Add the header row to the table
Table. Rows. Add (headerrow );
}
// Create the empty row
Gridviewrow emptyrow = New Gridviewrow ( - 1 , - 1 , Datacontrolrowtype. emptydatarow, datacontrolrowstate. Normal );
Tablecell Cell = New Tablecell (); itzhe.cn
Cell. columnspan = Fields. length;
Cell. Width = Unit. percentage ( 100 );
// Respect the precedence order if both emptydatatemplate
// And emptydatatext are both supplied
If ( This . Emptydatatemplate ! = Null )
{
This . Emptydatatemplate. instantiatein (cell );
}
Else If ( ! String . Isnullorempty ( This . Emptydatatext ))
{
Cell. Controls. Add ( New Literalcontrol (emptydatatext ));
IT staff
}
Emptyrow. cells. Add (cell );
Table. Rows. Add (emptyrow );
// If (this. showfooterwhenempty)
// {
// Create footer row
Gridviewrow footerrow = Base . Createrow ( - 1 , - 1 , Datacontrolrowtype. footer, datacontrolrowstate. Normal );
This . Initializerow (footerrow, fields );
//Add the footer to the table
Table. Rows. Add (footerrow );
//}
This. Controls. Clear ();
Www.itzhe.cn
This. Controls. Add (table );
This. Showfooter= True;
}
ReturnRows;
}
}
The function is implemented. When no data is available, both the header and footer can be displayed. I put all the items to be entered for data insertion in footer. Therefore, when no data is available, an insert record will always be displayed, however, after I submit the request, the gridview. footerrow. findcontrol ("tb_foot_name") returns a null value. However, if the table contains data, the gridview. footerrow. findcontrol ("tb_foot_name") can return objects. The difference is:
However, if there is no data, footer is created by myself, and if there is data, footer is created by the system.
How can I help you?
Thank you.
This articleArticleSource from www.itzhe.cn Original article link: http://www.itzhe.cn/html/web/ASP.NET/20071127/22928_2.html