GridView里面的CheckBox列
我在网页中的代码
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
</div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="Name" HeaderText="姓名" />
<asp:CheckBoxField DataField="ishas" HeaderText="有无" />
</Columns>
</asp:GridView>
</form>
</body>
cs中的
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
List<Persion> ls = new List<Persion>();
Persion p = new Persion();
p.name = "王强";
p.isHas = false;
ls.Add(p);
p = new Persion();
p.name = "王三";
p.isHas = true;
ls.Add(p);
GridView1.DataSource = ls;
GridView1.DataBind();
}
}
怎样才能让Checkbox可以用来选取和取消呢
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
</div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="Name" HeaderText="姓名" />
<asp:CheckBoxField DataField="ishas" HeaderText="有无" />
</Columns>
</asp:GridView>
</form>
</body>
cs中的
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
List<Persion> ls = new List<Persion>();
Persion p = new Persion();
p.name = "王强";
p.isHas = false;
ls.Add(p);
p = new Persion();
p.name = "王三";
p.isHas = true;
ls.Add(p);
GridView1.DataSource = ls;
GridView1.DataBind();
}
}
怎样才能让Checkbox可以用来选取和取消呢
作者: e_board 发布时间: 2011-06-15
可以看看那个老掉牙的asp.net2.0编程入门教程:
http://blog.csdn.net/heker2007/archive/2007/03/31/1547371.aspx
http://blog.csdn.net/heker2007/archive/2007/03/31/1547371.aspx
作者: sp1234 发布时间: 2011-06-15
随便找个教程看看吧
参考
参考
作者: wxr0323 发布时间: 2011-06-15