In the GridView, get the values in the DropDownList and textbox of the clicked line.

Source: Internet
Author: User
This article describes how to click the "a" in the GridView to get the click of the Drop-down box in the line and the value of the text box, the specific implementation of the whine is as follows, interested friends can refer to ha, I hope to help you

ASPX page code: Get the Drop-down box and the value in the text box in the clicked line by clicking a tag in the GridView

Copy Code code as follows:


<asp:gridview id= "GridView1" runat= "Server" >


<Columns>


<asp:boundfield headertext= "id" datafield= "id"/>


<asp:boundfield headertext= "Name" datafield= "ID"/>


<asp:boundfield headertext= "Url" datafield= "ID"/>


<asp:TemplateField>


<ItemTemplate>


<asp:dropdownlist id= "DropDownList1" runat= "Server" >


<asp:listitem value= "0" > Privacy </asp:ListItem>


<asp:listitem value= "1" > Male </asp:ListItem>


<asp:listitem value= "2" > Female </asp:ListItem>


</asp:DropDownList>


</ItemTemplate>


</asp:TemplateField>


<asp:TemplateField>


<ItemTemplate>


<asp:textbox id= "txtdate" runat= "Server" ></asp:TextBox>


</ItemTemplate>


</asp:TemplateField>


<asp:TemplateField>


<ItemTemplate>


<a href= "#" onclick= "Save (this);" >Save</a>


</ItemTemplate>


</asp:TemplateField>


</Columns>


</asp:GridView>


jquery Code:

Copy Code code as follows:


<script src= "... /scripts/jquery-1.4.1.js "type=" Text/javascript "></script>
<script language=" javascript "type=" Text/javascript >
Function Save (obj) {
var tr = $ (obj). Parent (). parent ();//Get the TR
Tr.find ("TD") that clicks on the line. EQ (3 ). Find ("select"). Val (); Get the fourth column in the line DropDownList1 select value
Tr.find ("TD"). EQ (3). Find ("select"). Text ();//Get the fourth column of the clicked Row DropDownList1 The Select Text
Tr.find ("TD"). EQ (4). Find ("Input"). val ();//Get Click on the fourth column TextBox Text

</script>

in the row

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.