In the GridView, get the values in the DropDownList and textbox in the clicked Row _jquery

Source: Internet
Author: User
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" > Women </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 for the clicked Line
Tr.find ("TD"). EQ (3). Find ("select"). Val (); Get the fourth column in the clicked row DropDownList1 Select Value
Tr.find ("TD"). EQ (3). Find ("select"). Text (); Get the fourth column in the hit line DropDownList1 select text
Tr.find ("TD"). EQ (4). Find ("Input"). Val (); Get the fourth column TextBox Text in the clicked row
}
</script>

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.