使用radiobutton创建gridview并在C#asp.net中捕获选定的radiobutton [英] Create gridview with radiobutton and capture selected radiobutton in C# asp.net

查看:82
本文介绍了使用radiobutton创建gridview并在C#asp.net中捕获选定的radiobutton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在项目模板字段中创建了带有radiobutton的gridview。



i有绑定在gridview中id为radiobutton。

但我不想显示它,因为它是主键,用户不需要看到



HOw隐藏它并在Submit按钮上捕获选定的radiobutton值。

Hi,

I have created gridview with radiobutton in item template field.

i have bind id to radiobutton in gridview.
But i dont want to display it because it is primary key and user need not to see that

HOw to hide that and capture selected radiobutton value on Submit button.

推荐答案

使用Checkbox从gridview中选择行总是好的。这样用户可以同时选择多行。

这里我做了一个简单的演示。

你的Gridview:

It is always good to take Checkbox to select the row from gridview. So that user can select multiple row same time.
here i have made a simple demo.
Your Gridview :
<asp:gridview id="gridview" runat="server" autogeneratecolumns="false" xmlns:asp="#unknown">
          <columns>
              <asp:templatefield headertext="Select">
                  <HeaderTemplate>
                      <span title="Select">Select</span>
                      <asp:checkbox id="chkAddAllProd" onclick="checkUncheckAll(this)" tooltip="Select All">
                          runat="server" value="1" BorderStyle="None"></asp:checkbox>
                  </HeaderTemplate>
                  <itemtemplate>
                      <asp:checkbox id="chkAddProduct" runat="server" value="<%# Eval("Id")%>" borderstyle="None">
                      </asp:checkbox>
                  </itemtemplate>
              </asp:templatefield>
              <%--Your other template field--%>
          </columns>
      </asp:gridview>


你也可以通过选择标题复选框来选择所有行:

这里是jquery代码:


You can also select all the row by selecting the header checkbox :
here is the jquery code :

function checkUncheckAll(chk) {


' #<%= gridview.ClientID%>')。find( 输入:复选框)。每个( function (){
if this != chk){
this .checked = chk.checked;
}
});
}
('#<%=gridview.ClientID %>').find("input:checkbox").each(function () { if (this != chk) { this.checked = chk.checked; } }); }





希望它能为您提供帮助。



祝你好运。



Hope it will help you.

Good luck.


这篇关于使用radiobutton创建gridview并在C#asp.net中捕获选定的radiobutton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆