Get the DropDownList and TextBox values in the row to be clicked in the GridView.

Source: Internet
Author: User

Aspx page code: Click the tab in the GridView to obtain the values in the drop-down box and text box in the row to be clicked.
Copy codeThe Code is 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"> confidentiality </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 codeThe Code is 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 of the clicked row
Tr. find ("td"). eq (3). find ("select"). val (); // obtain the selected Value of DropDownList1 in the fourth column of the row.
Tr. find ("td"). eq (3). find ("select"). text (); // obtain the selected Text of DropDownList1 in the fourth column of the row.
Tr. find ("td"). eq (4). find ("input"). val (); // obtain the TextBox Text column in the row to be clicked.
}
</Script>

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.