如何在Gridview中添加一个复选框? [英] How to add a checkbox in Gridview ?
本文介绍了如何在Gridview中添加一个复选框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Gridview中添加复选框???
有人可以教我如何在gridview中添加复选框吗?
i从添加新列添加,但是当我运行我的页面时复选框不是功能,意味着它无法检查
有人可以详细教我吗?因为我是ASP.Net 2.0的新手(使用Visual Studio 2013)
如果可能的话,我想检索被检查的数据库行的列值中的一个
有人可以教我这个吗?
谢谢[:]]
How to add a checkbox in Gridview ???
Can someone please teach me how to add a checkbox in gridview?
i added from the add new columns,but the checkbox is not fuctioning when i run my page,means it can't be check
can someone please teach me in detail?coz i am new in ASP.Net 2.0 ( Using Visual Studio 2013)
and if possible,i wan to retrieve 1 of the column value of the database row which being checked
can someone teach me this as well?
thanks[:)]
推荐答案
你看到这个博客:
http://stackoverflow.com/questions/14781735/asp-net-mvc-check-gridview-checkboxes [ ^ ]
Did you see this blog:
http://stackoverflow.com/questions/14781735/asp-net-mvc-check-gridview-checkboxes[^]
You need to define a checkbox column as a TemplateField.
Below is an example showing how to retrieve the key of each checked item.
CheckBoxExample.aspx
view sourceprint?
01 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="CheckBoxExample.aspx.cs" Inherits="CheckBoxExample" %>
02
03 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
04
05 <html xmlns="http://www.w3.org/1999/xhtml" >
06 <head runat="server">
07 <title>CheckBox Example</title>
08 </head>
09 <body>
10 <form id="form1" runat="server">
11 <div>
12 <asp:GridView ID="ProductGridView" runat="server" AutoGenerateColumns="False" DataKeyNames="ItemId">
13 <Columns>
14 <asp:BoundField DataField="ItemDescription" DataFormatString="{0}" HeaderText="Item" />
15 <asp:BoundField DataField="ItemPrice" DataFormatString="{0:C}" HeaderText="Price" />
16 <asp:TemplateField HeaderText="Purchase">
17 <ItemTemplate>
18 <asp:CheckBox ID="CheckBoxPurchase" runat="server" Enabled="true" />
19 </ItemTemplate>
20 </asp:TemplateField>
21 </Columns>
22 </asp:GridView>
23 <asp:Button ID="Purchase" runat="server" Text="Purchase Checked Items" />
24 </div>
25 </form>
26 </body>
27 </html>
这篇关于如何在Gridview中添加一个复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文