这是我想要做的代码,但它无法正常工作
$("#a_btn").click(function ()
{
if(('table[id*="GridView_Customer"] input[type="radio"]:checked'))
{
var lblStatus = $('table[id*="GridView_Customer"] [id*="lblStatus"]').text();
alert(lblStatus);
}
}
当我选择“RadioButton_Select”并点击a_btn时需要获取“lblStatus”值
提前致谢
编辑1 包括html:
<a id="a_btn">cancel</a>
//Anchor tag
<asp:gridview id="GridView_Customer" autogeneratecolumns="false" runat="server" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:RadioButton runat="server" id="RadioButton_Select" AutoPostBack="True"> </asp:RadioButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField >
<ItemTemplate>
<asp:Label ID="lblStatus" Text='<%# Eval("Status") %>' width="80px" runat="server"> </asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Coloumns>
</asp:Gridview>
答案 0 :(得分:1)
<asp:gridview id="GridView_Customer" autogeneratecolumns="false" runat="server" OnRowCommand="gdBankDetils_RowCommand" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:RadioButton runat="server" id="RadioButton_Select" AutoPostBack="True"> </asp:RadioButton>
<asp:HiddenField ID="hdnId" Value='<%#Eval("Id") %>' runat="server"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField >
<ItemTemplate>
<asp:Label ID="lblStatus" Text='<%# Eval("Status") %>' width="80px" runat="server"> </asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Coloumns>
</asp:Gridview>
代码背后
protected void GridView_Customer_RowCommand(object sender, GridViewCommandEventArgs e)
{
//Perform Action
}
答案 1 :(得分:0)
您需要在网格外添加隐藏字段,单击单选按钮后,只需使用给定的命令名称在gridview onrowcommand事件中设置隐藏字段值。 当点击锚点按钮时,你只需从隐藏字段中获取值..
可能会解决你的问题。
感谢....