ASPxGridView利用CheckBox实现全选本篇介绍:ASPxGridView 结合CheckBox实现多选 ,实质跟gridview是一样的:遍历ASPxGridView 找到每行的CheckBox,让后做处理。不过ASPxGridView 在遍历的时候有很多地方和gridview是不同的,对于和我一样对ASPxGridView 不属性的人来说,要花很多的事件去找和适当属性。
其实ASPxGridView 官方也提供了实现全选的例子不过那个似乎是不能绑定数据库的。
遍历ASPxGridView 时findcontrol事要注意要用 (CheckBox)ASPxGridView1.FindRowCellTemplateControl(i, (GridViewDataColumn)ASPxGridView1.Columns["SelectAll"], "CheckBox1")来取得某行的CheckBox
还有记得要把head的CheckBox的设置AutoPostBack="True" ,负责当点击CheckBox时相当与head的click。
下面是详细代码:
后台代码:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DevExpress.Web.ASPxGridView;
public partial class 结合checkbox_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余4页未读,立即下载