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>