DataGrid Colum名称 [英] DataGrid Colum Names

查看:57
本文介绍了DataGrid Colum名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,如果我可以获得

数据网格中colums的名称,那将非常有用。


例如


dim datagrid1 as new datagrid

datagrid1.datasource =(加载datagrid的存储过程)

datagrid1.databind()


我能够通过相对数量获取数据网格中的数据但是

我无法弄清楚如何获取名称,在这个应用程序中他们可能

随时间变化。


任何帮助都会非常感激!


谢谢,


Fred

解决方案

如果它绑定到网格,那么网格列应该与
列。因此,您可以查询

DataTable的列的集合,只需查找ColumnName属性即

DataTable.Columns [0] .ColumnName;


HTH,

bill

Fred Nelson < FR ** @ smartybird.com>在消息中写道

新闻:OW ************** @ TK2MSFTNGP09.phx.gbl ...

我有一个申请表如果我能在
中获取数据网格中colums的名称,那将是非常有益的。

例如

dim datagrid1 as new datagrid
datagrid1.datasource =(加载datagrid的存储过程)
datagrid1.databind()

我能够通过相对数字
获取数据网格中的数据但是我可以'弄清楚如何获得名称,在这个应用程序中,他们可能会随着时间的推移而改变。

任何帮助都会非常感激!

谢谢,

Fred



Bill:


感谢您的回复 - 它看起来我可以让它工作!


我不明白一件事 - 在我提供的示例中,我将

数据网格绑定到带有加载它的存储过程的类库。我是

不清楚如何在这个例子中引用基础数据表

datagrid1包含数据。


DataGrid1 .Colums [0] .ColumnName语法无效 -


我是否需要从存储过程而不是
数据网格创建数据表 - 或者有什么我想念的吗?


再次感谢您的帮助!


Fred

" ; William Ryan eMVP <双** @ NoSp4m.devbuzz.com>在消息中写道

新闻:uL ************** @ TK2MSFTNGP12.phx.gbl ...

如果是的话绑定到网格,然后网格列应与基础数据表中的
列对应。因此,您可以查询
DataTable的列的集合,只需查找ColumnName属性即
DataTable.Columns [0] .ColumnName;

HTH,

账单
Fred Nelson < FR ** @ smartybird.com>在消息中写道
新闻:OW ************** @ TK2MSFTNGP09.phx.gbl ...

我有一个应用程序,它将是非常有益,如果我能


获取

数据网格中colums的名称。

例如

dim datagrid1作为新的datagrid
datagrid1.datasource =(加载datagrid的存储过程)
datagrid1.databind()

我能够通过其相对数量获取datagrid中的数据


然而

我无法弄清楚如何获取名称,在这个应用程序中,他们可能会随着时间的推移而改变。
任何帮助都将非常感谢!

谢谢,




Fred:


您将引用绑定到网格的DataTable。无论它的名字是什么,请参考它。如何填充(即存储过程)并不重要。

根据您调用DataAdapter.Fill的方式,您可能想要使用

数字指数表集合即

myDataSet.Tables [0] .Columns [0] .ColumnName;


从概念上讲,专注于用你想要的wahtever命中数据源。

网格只是底层数据obejct的表示。在网上,

变化不一定会在发生回发之前明显反映出来,但是一旦你更改了基础表值,桌面就会显示


以编程方式,更改将立即在网格中显示。


HTH,


Bill

Fred Nelson < FR ** @ smartybird.com>在消息中写道

新闻:eT ************** @ TK2MSFTNGP10.phx.gbl ...

Bill:

感谢您的回复 - 看起来我可以让这个工作!

我不明白一件事 - 在我提供的示例中我绑定了
数据网格到类库,其中包含加载它的存储过程。我不清楚如何在这个示例中引用基础数据表,其中
datagrid1包含数据。

DataGrid1.Colums [0] .ColumnName语法无效 -

我是否需要从存储过程而不是数据网格创建数据表 - 或者是否有我遗漏的东西?

再次感谢为了你的帮助!

Fred

" William Ryan eMVP" <双** @ NoSp4m.devbuzz.com>在消息中写道
新闻:uL ************** @ TK2MSFTNGP12.phx.gbl ...

如果它绑定到网格,然后网格列应与基础数据表中的
列对应。因此,您可以查询
DataTable的列的集合,只需查找ColumnName属性
即DataTable.Columns [0] .ColumnName;

HTH,

账单
Fred Nelson < FR ** @ smartybird.com>在消息中写道
新闻:OW ************** @ TK2MSFTNGP09.phx.gbl ...

我有一个应用程序,它将是非常有益,如果我能


获取

数据网格中colums的名称。

例如

dim datagrid1作为新的datagrid
datagrid1.datasource =(加载datagrid的存储过程)
datagrid1.databind()

我能够通过其相对数量获取datagrid中的数据


然而

我无法弄清楚如何获取名称,在这个应用程序中,他们
可能会随着时间的推移而改变。
任何帮助都将非常感谢!

谢谢,





I have an application in which it would be VERY beneficial if I could obtain
the names of the colums in a datagrid.

For example

dim datagrid1 as new datagrid
datagrid1.datasource = (stored procedure that loads datagrid)
datagrid1.databind()

I am able to obtain the data in the datagrid by its relative number however
I can''t figure out how to get the names and in this application they may
change over time.

Any help would be GREATLY appreciated!

Thanks,

Fred

解决方案

If it''s bound to a grid, then the grid column should correspond with the
columns in the underlying datatable. As such, you can interrogate the
DataTable''s column''s collection and just lookup the ColumnName property ie
DataTable.Columns[0].ColumnName;

HTH,

bill
"Fred Nelson" <fr**@smartybird.com> wrote in message
news:OW**************@TK2MSFTNGP09.phx.gbl...

I have an application in which it would be VERY beneficial if I could obtain the names of the colums in a datagrid.

For example

dim datagrid1 as new datagrid
datagrid1.datasource = (stored procedure that loads datagrid)
datagrid1.databind()

I am able to obtain the data in the datagrid by its relative number however I can''t figure out how to get the names and in this application they may
change over time.

Any help would be GREATLY appreciated!

Thanks,

Fred



Bill:

Thanks for your reply - it looks like I may get this to work!

I don''t understand one thing - in the example that I provided I bound the
data grid to a class library with a stored procedure that loaded it. I''m
unclear how to reference the underlying data table in this example where
datagrid1 contains the data.

DataGrid1.Colums[0].ColumnName is not valid syntax -

Do I need to create a data table from the stored procedure rather than a
data grid - or is there something I''m missing?

Thanks again for your help!

Fred
"William Ryan eMVP" <bi**@NoSp4m.devbuzz.com> wrote in message
news:uL**************@TK2MSFTNGP12.phx.gbl...

If it''s bound to a grid, then the grid column should correspond with the
columns in the underlying datatable. As such, you can interrogate the
DataTable''s column''s collection and just lookup the ColumnName property ie
DataTable.Columns[0].ColumnName;

HTH,

bill
"Fred Nelson" <fr**@smartybird.com> wrote in message
news:OW**************@TK2MSFTNGP09.phx.gbl...

I have an application in which it would be VERY beneficial if I could


obtain

the names of the colums in a datagrid.

For example

dim datagrid1 as new datagrid
datagrid1.datasource = (stored procedure that loads datagrid)
datagrid1.databind()

I am able to obtain the data in the datagrid by its relative number


however

I can''t figure out how to get the names and in this application they may
change over time.

Any help would be GREATLY appreciated!

Thanks,

Fred




Fred:

You''ll reference the DataTable that you bound the grid to. Whatever it''s
name is, reference it. How it got filled (ie Stored Proc) doesn''t matter.
Depending on how you called DataAdapter.Fill, you may want to use the
Numeric Index of hte Tables collection ie
myDataSet.Tables[0].Columns[0].ColumnName;

conceptually, focus on hitting the datasource with wahtever you want. The
grid is just the presentation of the underlying data obejct. On the Web,
changes won''t necessarily be reflected visibly until a postback occurs, but
on the desktop, as soon as you change the underlying table value
programmatically, the change will be visible in the Grid immediately.

HTH,

Bill
"Fred Nelson" <fr**@smartybird.com> wrote in message
news:eT**************@TK2MSFTNGP10.phx.gbl...

Bill:

Thanks for your reply - it looks like I may get this to work!

I don''t understand one thing - in the example that I provided I bound the
data grid to a class library with a stored procedure that loaded it. I''m
unclear how to reference the underlying data table in this example where
datagrid1 contains the data.

DataGrid1.Colums[0].ColumnName is not valid syntax -

Do I need to create a data table from the stored procedure rather than a
data grid - or is there something I''m missing?

Thanks again for your help!

Fred
"William Ryan eMVP" <bi**@NoSp4m.devbuzz.com> wrote in message
news:uL**************@TK2MSFTNGP12.phx.gbl...

If it''s bound to a grid, then the grid column should correspond with the
columns in the underlying datatable. As such, you can interrogate the
DataTable''s column''s collection and just lookup the ColumnName property ie DataTable.Columns[0].ColumnName;

HTH,

bill
"Fred Nelson" <fr**@smartybird.com> wrote in message
news:OW**************@TK2MSFTNGP09.phx.gbl...

I have an application in which it would be VERY beneficial if I could


obtain

the names of the colums in a datagrid.

For example

dim datagrid1 as new datagrid
datagrid1.datasource = (stored procedure that loads datagrid)
datagrid1.databind()

I am able to obtain the data in the datagrid by its relative number


however

I can''t figure out how to get the names and in this application they may change over time.

Any help would be GREATLY appreciated!

Thanks,

Fred





这篇关于DataGrid Colum名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆