社区
C#
帖子详情
如何取得在DataGrid的Header中的控件的值?
cyanman
2003-07-30 09:03:28
我在Header中放了一个CheckBox控件,但怎么也取不到它的值,我用
if(((CheckBox)DataGrid1.FindControl("cbxAll")).Checked)
{
。。。
}
提示未将对象应用到实例。
请问各位高手,如何解决?
...全文
144
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
内容居
中
1、充满布局 显示设置
DataGrid
TextColumn的属性Width=“*” 实现
DataGrid
控件
宽充满布局,代码与效果图片如下所示: 2、
Header
居
中
显示 WPF
DataGrid
属性
中
无
DataGrid
的
Header
居
中
显示属性,可在xaml代码
中
添加 设置风格代码 设置,代码如下: <!-- 设置
Header
居
中
--> <
DataGrid
.Colum...
获取
DataGrid
的Footer
中
的
控件
今天又整理出一篇footer的文章。很多情况下由于需要都会在footer
中
放入一些
控件
,但是最后在获得这些
控件
引用的时候就会遇到点小麻烦,由于footer,
header
,pager都不在
DataGrid
.Items属性
中
,该属性返回的集合只包含数据绑定生成的item,所以必须用其他方法来做。下面是我从csdn和其他地方总结而来的几种方法:1.在IteamCreated或者ItemDataBound
datagrid
分页时的
控件
Datagrid
控件
分页时,我们发现datagird按如下顺序创建行(假设我们先把datagird 的allowpaging属性设为 true):Pager?
Header
?Item? AlternatingItem?Item? AlternatingItem? Item?……(直至创建完所有内容行)?Footer?Pager 下面的分页导航如果是当前页,则是一个label
控件
,如果不是当
WPF
DataGrid
标题
Header
Binding失效
前言:因业务需要对WPF
中
的
DataGrid
控件
中
的行数进行统计,同时把统计的行数显示在列标题上。 如果我们用常规的Binding手段更新
DataGrid
TextColunm的
Header
的话是不会生效的,因为WPF
中
视觉树
中
没有
DataGrid
TextColumn元素来映射它(
DataGrid
TextColumn不是
控件
,因此它没有父
控件
)。 错误示范: <
DataGrid
Te...
Wpf
中
的
DataGrid
的
Header
属性,动态bind时不起作用
在使用wpf开发软件时,有使用到
DataGrid
,
DataGrid
TextColumn的
Header
属性使用DynamicResource binding,在修改绑定数据源时,
header
并没有更新。 <
DataGrid
TextColumn
Header
="{DynamicResource test_Main_Result_ID}" Width="30*" Binding="{Binding ID,Mode=TwoWay}" IsReadOnly="True" CanUserSort="Fals.
C#
111,128
社区成员
642,536
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章