asp.net the GridView template column to implement the Select Line function _ Practical Tips

Source: Internet
Author: User

Most of the functionality is implemented through template columns, in order to easily select and delete the use of its own features and methods, it is easy to achieve, did not find any major problems, but in the deployment to the server, found that the choice is not to display text, but "select", also did not find out what the reason, The following have to be implemented by template columns instead.
When changing to a template column implementation, found that the Gv_sjy_rowcommand event can not get the index of the row through E.commandargument, can only think of ways, found that there are two ways to do:
First Type:

Copy Code code as follows:

<asp:linkbutton id= "Btnselect" runat= "Server" causesvalidation= "False" commandname= "select" text= "Choose" Commandargument= "<%# (gridviewrow) Container). RowIndex%> "></asp:LinkButton>

Add a red section to the background to pass int rowIndex = Convert.ToInt32 (e.commandargument); Get the index value of the row
  
The second type:
Copy Code code as follows:

protected void Gv_sjy_rowcommand (object sender, Gridviewcommandeventargs e)
{
if (E.commandname = = "Select")
{
GridViewRow Gvrow = (GridViewRow) ((LinkButton) e.commandsource). Parent.parent);
int rowIndex = gvrow.rowindex;//Gets the selected row index
Txtsjyxh.text = DT2. rows[rowindex]["Sjyxh"]. ToString ();
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.