asp.net gets the data control event index and gets the middle value summary

  • 2020-05-12 02:32:11
  • OfStack

 
1 , RowCommad 
// To obtain the index  
int index = ((GridViewRow)(((Button)(e.CommandSource)).Parent.Parent)).RowIndex; 

2 , RowEditing Etc.  
// To obtain the index  
int index = e.NewEditIndex; 
// Gets the current GridViewRow object  
GridViewRow editGridViewRow = autoGridView.Rows[girdviewEditIndex]; 

// Get content method 1 row The control of Label 
Label girdviewTitleLabel = editGridViewRow.Cells[0].FindControl("titleLabel") as Label; 
string gridViewContent = girdviewTitleLabel.Text; 
// Get content method 2 row Whether there are controls in Label 
//string gridViewContent = editGridViewRow.Cells[0].Text; 

3 , RowDeleting Etc.  
// To obtain the index  
int index=e.RowIndex ; 
// Gets the current GridViewRow object  
GridViewRow gvr=autoGridView.Rows[index]; 
// Gets the current line number 2 The text in a cell  
string str = gvr.Cells[1].Text; 

Related articles: