社区
C#
帖子详情
如何取得在DataGrid的Header中的控件的值?
cyanman
2003-07-30 09:03:28
我在Header中放了一个CheckBox控件,但怎么也取不到它的值,我用
if(((CheckBox)DataGrid1.FindControl("cbxAll")).Checked)
{
。。。
}
提示未将对象应用到实例。
请问各位高手,如何解决?
...全文
140
6
打赏
收藏
如何取得在DataGrid的Header中的控件的值?
我在Header中放了一个CheckBox控件,但怎么也取不到它的值,我用 if(((CheckBox)DataGrid1.FindControl("cbxAll")).Checked) { 。。。 } 提示未将对象应用到实例。 请问各位高手,如何解决?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
6 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
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这样的类。
WPF:实现
DataGrid
控件
宽充满布局 及
Header
内容居
中
本文介绍了如何使用WPF
DataGrid
控件
实现充满布局,并通过设置样式使
Header
居
中
显示。提供了具体的代码示例,帮助开发者优化
DataGrid
的显示效果。
获取
DataGrid
的Footer
中
的
控件
文章主要讲述在
DataGrid
的footer
中
放入
控件
后,获取这些
控件
引用会遇到麻烦,因为footer、
header
、pager不在
DataGrid
.Items属性
中
。作者总结了四种获取footer
控件
引用的方法,包括在IteamCreated或ItemDataBound
中
操作、遍历
DataGrid
的所有Item等。
datagrid
分页时的
控件
本文详细介绍了
Datagrid
控件
在实现分页功能时的行创建顺序,并解释了不同页面状态下所使用的
控件
类型,包括Label、LiteralControl及
DataGrid
LinkButton等。
WPF
DataGrid
标题
Header
Binding失效
本文介绍如何在WPF的
DataGrid
控件
中
统计行数,并将该信息显示在列标题上。通过使用
DataGrid
TextColumn的
Header
Template和DataTemplate结合相对源绑定,实现动态更新列标题的行数。
Wpf
中
的
DataGrid
的
Header
属性,动态bind时不起作用
本文探讨了在WPF开发
中
使用
DataGrid
时,如何解决
Header
动态资源绑定不更新的问题。通过在
Header
中
嵌套TextBlock并进行绑定,实现了
Header
的动态显示效果。
C#
111,129
社区成员
642,541
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章