社区
C#
帖子详情
如何取得在DataGrid的Header中的控件的值?
cyanman
2003-07-30 09:03:28
我在Header中放了一个CheckBox控件,但怎么也取不到它的值,我用
if(((CheckBox)DataGrid1.FindControl("cbxAll")).Checked)
{
。。。
}
提示未将对象应用到实例。
请问各位高手,如何解决?
...全文
116
6
打赏
收藏
如何取得在DataGrid的Header中的控件的值?
我在Header中放了一个CheckBox控件,但怎么也取不到它的值,我用 if(((CheckBox)DataGrid1.FindControl("cbxAll")).Checked) { 。。。 } 提示未将对象应用到实例。 请问各位高手,如何解决?
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用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这样的类。
DataGrid
和ADO Data
控件
的使用
在Windows编程
中
,
DataGrid
控件
和ADO Data
控件
是常用的工具,用于显示和操作数据库
中
的数据。本文将深入探讨这两个
控件
的使用方法。 首先,我们来看
DataGrid
控件
。
DataGrid
通常用来以表格形式展示数据库
中
的数据,...
wpf加载图片到
datagrid
动态
控件
本教程将详细介绍如何在VS2010环境下,利用C#编程语言实现在WPF项目
中
动态加载图片并显示在
DataGrid
控件
中
。 首先,我们需要创建一个WPF项目。打开Visual Studio 2010,选择“文件” > “新建” > “项目”,在项目...
在
DataGrid
控件
中
动态隐藏显示指定列
在.NET框架
中
,
DataGrid
控件
是用于展示数据表格的常用组件,特别是在Windows Forms和WPF应用程序
中
。本文将深入探讨如何在
DataGrid
控件
中
动态隐藏或显示指定列,以便根据用户需求或应用程序逻辑调整界面展示。 首先...
DataGrid
中
嵌入comBox
在Windows Presentation Foundation(WPF)开发
中
,
DataGrid
控件
是一种强大的工具,用于展示和编辑表格数据。在某些场景下,我们可能需要在
DataGrid
的某一列
中
嵌入ComboBox
控件
,以提供用户多选或者下拉选择的功能。...
VB
中
DataGrid
_
控件
的使用秘集
在VB(Visual Basic)编程环境
中
,
DataGrid
控件
是一个非常重要的工具,用于显示和操作数据库
中
的数据。这个
控件
在Windows应用程序
中
广泛使用,因为它能够为用户提供一个清晰、直观的数据查看和编辑界面。下面,我们...
C#
111,092
社区成员
642,554
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章