社区
C#
帖子详情
如何取得在DataGrid的Header中的控件的值?
cyanman
2003-07-30 09:03:28
我在Header中放了一个CheckBox控件,但怎么也取不到它的值,我用
if(((CheckBox)DataGrid1.FindControl("cbxAll")).Checked)
{
。。。
}
提示未将对象应用到实例。
请问各位高手,如何解决?
...全文
108
6
打赏
收藏
如何取得在DataGrid的Header中的控件的值?
我在Header中放了一个CheckBox控件,但怎么也取不到它的值,我用 if(((CheckBox)DataGrid1.FindControl("cbxAll")).Checked) { 。。。 } 提示未将对象应用到实例。 请问各位高手,如何解决?
复制链接
扫一扫
分享
举报
写回复
配置赞助广告
6 条
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
打赏红包
cyanman
2003-07-31
打赏
举报
回复
如果今天下午不下雨的话,俺就去公园睡觉。
如果今天晚上问题还没有解决的话,俺就准备买单。
SimonSnow
2003-07-30
打赏
举报
回复
检查一下你的CheckBox的Name属性。(AssembleName?)
因为FindControl的参数是控件的name而不是控件变量的名字
好运
2003-07-30
打赏
举报
回复
good
雪狼1234567
2003-07-30
打赏
举报
回复
没有实例化,参考如下的代码:
// code assumes you have a DataSet named myDataSet, a table named "EastCoastSales" and a DataGrid myDataGrid
//STEP 1: Create a DataTable style object and set properties if required.
DataGridTableStyle ts1 = new DataGridTableStyle();
//specify the table from dataset (required step)
ts1.MappingName = "EastCoastSales";
// Set other properties (optional step)
ts1.AlternatingBackColor = Color.LightBlue;
//STEP 2: Create a string column and add it to the tablestyle
DataGridColumnStyle TextCol = new DataGridTextBoxColumn();
TextCol.MappingName = "custName"; //from dataset table
TextCol.HeaderText = "Customer Name";
TextCol.Width = 250;
ts1.GridColumnStyles.Add(TextCol);
//STEP 3: Create an int column style and add it to the tablestyle
//this requires setting the format for the column through its property descriptor
PropertyDescriptorCollection pdc = this.BindingContext
[myDataSet, "EastCoastSales"].GetItemProperties();
//now created a formated column using the pdc
DataGridDigitsTextBoxColumn csIDInt =
new DataGridDigitsTextBoxColumn(pdc["CustID"], "i", true);
csIDInt.MappingName = "CustID";
csIDInt.HeaderText = "CustID";
csIDInt.Width = 100;
ts1.GridColumnStyles.Add(csIDInt);
//STEP 4: Add the checkbox
DataGridColumnStyle boolCol = new DataGridBoolColumn();
boolCol.MappingName = "Current";
boolCol.HeaderText = "Info Current";
//uncomment this line to get a two-state checkbox
//((DataGridBoolColumn)boolCol).AllowNull = false;
boolCol.Width = 150;
ts1.GridColumnStyles.Add(boolCol);
//STEP 5: Add the tablestyle to your datagrid's tablestlye collection
myDataGrid.TableStyles.Add(ts1);
superxmz
2003-07-30
打赏
举报
回复
你用的是客户端的checkbox吗?
cyanman
2003-07-30
打赏
举报
回复
我忘了说一件很重要的事(我先掌自已一个大嘴巴),我这是在WEB页中的DataGrid,不能使用象DataGridColumnStyle这样的类。
相关推荐
一个ASP.NET
DataGrid
自定义
控
件,只需更改单个属性
值
即可冻结标题,行,列
一个ASP.NET
DataGrid
自定义
控
件,仅通过更改单个属性
值
就可以冻结
DataGrid
中
的标题,列和行。 它是从.NET
DataGrid
继承的,因此
DataGrid
的所有功能仍然可用。
asp.net
中
DataGrid
中
区各个单元格的
值
方法
asp.net
中
DataGrid
中
区各个单元格的
值
方法在asp.net
中
DataGrid
是一个功能强大的
控
件,用好了事半功倍阿。但是有些功能却让初学者痛苦。下面介绍在
DataGrid
中
怎么
取得
各个单元格的
值
。如果该列是按钮列的话可以直接取
值
,比如说:在方法ItemCommand
中
可以直接用string str=e.Item.Cells[N].Text//其
中
的N为在
DataGrid
中
的列
[原创]从DataGird
中
取得
模版列的
值
我做过的一个页面:要从
Datagrid
模版列
中
取得
绑定的
值
从网上一搜,发现大都用FindContol()方法,我也试过,用
DataGrid
.FindControl和e.Item.FindControl()取不到
值
如果,模版列
中
的
控
件设为Input html
控
件,
值
赋给input的Value则可以取到
值
,呵呵,郁闷了一天,通过跟踪e.Item.DataItem终于找到一个不错的方法;就...
GridView
中
如何
取得
隐藏列的
值
GridView
中
如何
取得
隐藏列的
值
在Asp.net2.0
中
增加了一个新的数据绑定
控
件:GridView,其目的用来取代Asp.net1.x
中
的
DataGrid
控
件,但有一点很不爽的是,如果把某列设置为visible=false,则不会进行数据绑定,也就是说无法直接从GridView
中
取到这个列内的文本。这一功能在
DataGrid
时代几乎是必须的,在对列表进行批量选
中
操作时非常有用...
Flex
控
件->
Datagrid
&Advanced
DataGrid
&DataGroup&List
[color=red]如何隐藏
DataGrid
的
Header
?[/color]
dataGrid
.show
Header
s = false [color=red]为啥我更新了
DataGrid
的dataProvider的item的属性
值
,
DataGrid
控
件却没有自动更新?[/color] 需要调用调用
DataGrid
的itemUpdate函数进行更新 示例代码: [code="fl...
发帖
C#
C#
.NET技术 C#
复制链接
扫一扫
10.8w+
社区成员
64.2w+
社区内容
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
帖子事件
创建了帖子
2003-07-30 09:03
社区公告
让您成为最强悍的C#开发者