[Reserved] GridView click anywhere in a row on the selected line

Original link: http://www.cnblogs.com/Echo529/p/4521701.html

GridView click anywhere on a row to select the row 
Category: 
First step: Select added row 
    on the right GridView small pointed, double-click CommandField, select the "Select", adding, will play a set invisible; 
the second step: Processing "ClientScriptManager.RegisterForEventValidation method to register the postback or callback data for validation", adding "enableEventValidation =" false "" in the source file; 
the third step: add the following code to the GridView's RowDataBound event: 
protected void GridView1_RowDataBound (Object SENDER , GridViewRowEventArgs E) 
{ 
     PostBackOptions myPostBackOptions = new new PostBackOptions (the this); 
     myPostBackOptions.AutoPostBack = to false; 
     myPostBackOptions.RequiresJavaScriptProtocol = to true; 
     myPostBackOptions.PerformValidation = to false; 
     String EVT = Page.ClientScript.GetPostBackClientHyperlink (SENDER the GridView AS, "the Select $" + e.Row.RowIndex.ToString ());
     e.Row.Attributes.Add ( "the onclick", EVT); 
} 
fourth step 3: Add the GridView's SelectedIndexChanged event you selected after a row wanted to do:
 protected void dataGridView1_SelectedIndexChanged(object sender, EventArgs e)
{
    //Functions you want to carry out;
}
OK!

 

Reproduced in: https: //www.cnblogs.com/Echo529/p/4521701.html

GridView click anywhere on a row to select the row 
Category: 
First step: Select added row 
    on the right GridView small pointed, double-click CommandField, select the "Select", adding, will play a set invisible; 
the second step: Processing "ClientScriptManager.RegisterForEventValidation method to register the postback or callback data for validation", adding "enableEventValidation =" false "" in the source file; 
the third step: add the following code to the GridView's RowDataBound event: 
protected void GridView1_RowDataBound (Object SENDER , GridViewRowEventArgs E) 
{ 
     PostBackOptions myPostBackOptions = new new PostBackOptions (the this); 
     myPostBackOptions.AutoPostBack = to false; 
     myPostBackOptions.RequiresJavaScriptProtocol = to true; 
     myPostBackOptions.PerformValidation = to false; 
     String EVT = Page.ClientScript.GetPostBackClientHyperlink (SENDER the GridView AS, "the Select $" + e.Row.RowIndex.ToString ());
     e.Row.Attributes.Add ( "the onclick", EVT); 
} 
fourth step 3: Add the GridView's SelectedIndexChanged event you selected after a row wanted to do:
 protected void dataGridView1_SelectedIndexChanged(object sender, EventArgs e)
{
    //Functions you want to carry out;
}
OK!

 

Guess you like

Origin www.cnblogs.com/bing-03/p/11460233.html