473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Get Column of DataGrid Web Control

I want to get the column name of a datagrid control. But DataGrid.Columns
always return a collection of count 0.

Thanks for your help in advance.
Nov 18 '05 #1
5 1200
Are you looking at DataGrid.Columns after databinding or before?

Eliyahu

"Laurence" <ha********@hotmail.com> wrote in message
news:OM**************@TK2MSFTNGP11.phx.gbl...
I want to get the column name of a datagrid control. But DataGrid.Columns
always return a collection of count 0.

Thanks for your help in advance.

Nov 18 '05 #2
Hi Eliyahu,

I looked at it after databinding. I can get the data from the datagrid but
cannot get the header.

Let me speak more about my request:

I am developing a component to import data from a datagrid. My users also
want to get the headers of the datagrid. However I don't know how to get the
headers. The returned Columns always contain no data.
The DataGrid.AutoGenerateColumns is true by default. I think maybe this
caused my problem but I have to create the columns dynamically.

"Eliyahu Goldin" <re*************@monarchmed.com> дÈëÏûÏ¢ÐÂÎÅ:eG**************@TK2MSFTNGP14.phx.gbl ...
Are you looking at DataGrid.Columns after databinding or before?

Eliyahu

"Laurence" <ha********@hotmail.com> wrote in message
news:OM**************@TK2MSFTNGP11.phx.gbl...
I want to get the column name of a datagrid control. But DataGrid.Columns
always return a collection of count 0.

Thanks for your help in advance.


Nov 18 '05 #3
Your guess is right. The following is taken from the MSDN:

The Columns collection contains explicitly declared columns that get
rendered in the DataGrid control.
Note Explicitly declared columns may be used in conjunction with
automatically generated columns. When using both, explicitly declared
columns will be rendered first, followed by the automatically generated
columns. Automatically generated columns are not added to the Columns
collection.
Eliyahu

"Laurence" <ha********@hotmail.com> wrote in message
news:Oq**************@TK2MSFTNGP10.phx.gbl...
Hi Eliyahu,

I looked at it after databinding. I can get the data from the datagrid but
cannot get the header.

Let me speak more about my request:

I am developing a component to import data from a datagrid. My users also
want to get the headers of the datagrid. However I don't know how to get the headers. The returned Columns always contain no data.
The DataGrid.AutoGenerateColumns is true by default. I think maybe this
caused my problem but I have to create the columns dynamically.

"Eliyahu Goldin" <re*************@monarchmed.com>

дÈëÏûÏ¢ÐÂÎÅ:eG**************@TK2MSFTNGP14.phx.gbl ...
Are you looking at DataGrid.Columns after databinding or before?

Eliyahu

"Laurence" <ha********@hotmail.com> wrote in message
news:OM**************@TK2MSFTNGP11.phx.gbl...
I want to get the column name of a datagrid control. But DataGrid.Columns always return a collection of count 0.

Thanks for your help in advance.



Nov 18 '05 #4
If you generate the columns automatically, you should be able to get their
names from your datasource.

Eliyahu

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:OX**************@TK2MSFTNGP11.phx.gbl...
Your guess is right. The following is taken from the MSDN:

The Columns collection contains explicitly declared columns that get
rendered in the DataGrid control.
Note Explicitly declared columns may be used in conjunction with
automatically generated columns. When using both, explicitly declared
columns will be rendered first, followed by the automatically generated
columns. Automatically generated columns are not added to the Columns
collection.
Eliyahu

"Laurence" <ha********@hotmail.com> wrote in message
news:Oq**************@TK2MSFTNGP10.phx.gbl...
Hi Eliyahu,

I looked at it after databinding. I can get the data from the datagrid but
cannot get the header.

Let me speak more about my request:

I am developing a component to import data from a datagrid. My users also want to get the headers of the datagrid. However I don't know how to get

the
headers. The returned Columns always contain no data.
The DataGrid.AutoGenerateColumns is true by default. I think maybe this
caused my problem but I have to create the columns dynamically.

"Eliyahu Goldin" <re*************@monarchmed.com>

дÈëÏûÏ¢ÐÂÎÅ:eG**************@TK2MSFTNGP14.phx.gbl ... Are you looking at DataGrid.Columns after databinding or before?

Eliyahu

"Laurence" <ha********@hotmail.com> wrote in message
news:OM**************@TK2MSFTNGP11.phx.gbl...
> I want to get the column name of a datagrid control. But DataGrid.Columns> always return a collection of count 0.
>
> Thanks for your help in advance.
>
>



Nov 18 '05 #5
Thank you.
But unfortunately I can't know the names from the datasource because I am
developing a class for other developers. I don't know what kind of data
source they may use.

"Eliyahu Goldin" <re*************@monarchmed.com> дÈëÏûÏ¢ÐÂÎÅ:%2***************@TK2MSFTNGP10.phx.gb l...
If you generate the columns automatically, you should be able to get their
names from your datasource.

Eliyahu

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:OX**************@TK2MSFTNGP11.phx.gbl...
Your guess is right. The following is taken from the MSDN:

The Columns collection contains explicitly declared columns that get
rendered in the DataGrid control.
Note Explicitly declared columns may be used in conjunction with
automatically generated columns. When using both, explicitly declared
columns will be rendered first, followed by the automatically generated
columns. Automatically generated columns are not added to the Columns
collection.
Eliyahu

"Laurence" <ha********@hotmail.com> wrote in message
news:Oq**************@TK2MSFTNGP10.phx.gbl...
> Hi Eliyahu,
>
> I looked at it after databinding. I can get the data from the datagrid but > cannot get the header.
>
> Let me speak more about my request:
>
> I am developing a component to import data from a datagrid. My users also > want to get the headers of the datagrid. However I don't know how to
> get

the
> headers. The returned Columns always contain no data.
> The DataGrid.AutoGenerateColumns is true by default. I think maybe this
> caused my problem but I have to create the columns dynamically.
>
> "Eliyahu Goldin" <re*************@monarchmed.com>

дÈëÏûÏ¢ÐÂÎÅ:eG**************@TK2MSFTNGP14.phx.gbl ...
> > Are you looking at DataGrid.Columns after databinding or before?
> >
> > Eliyahu
> >
> > "Laurence" <ha********@hotmail.com> wrote in message
> > news:OM**************@TK2MSFTNGP11.phx.gbl...
> >> I want to get the column name of a datagrid control. But

DataGrid.Columns
> >> always return a collection of count 0.
> >>
> >> Thanks for your help in advance.
> >>
> >>
> >
> >
>
>



Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Webgour | last post by:
Hi, I'm tring to add a column to a datagrid with a linkbutton as header that can be used to sort the column. The column and the linkbutton are added programmatically (see below). However the...
3
by: PeterZ | last post by:
Hi, In a running C# app with a datagrid control I select all rows in the dataGrid using CTRL-A, I then paste into some other app like notepad or Word but the column headings get left off. Is...
2
by: Raj | last post by:
Hi, When we are sorting the DataGrid Boolean column the grid is becoming redcross. I have my own PPMIPDataGridBoolColumn class inherited from System.Windows.Forms.DataGridBoolColumn. In this...
2
by: shahbaz | last post by:
Hi all, I'm kinda new to asp.net. I'm using a datagrid which shows data from a table...simple enough. Now I have a javascript (which I found on the web) which allows me to hide/show (or...
1
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get...
6
by: Agnes | last post by:
I understand it is impossible, but still curious to know "Can I freeze several column in the datagrid, the user can only scroll the first 3 columns (not verical), for the rest of the coulumn, it is...
3
by: chreo | last post by:
Hello. I have datagrid. I found code to select all row in data grid (by mouse or arrow keys). This works great - user can select row and... ....and I want to go to next control. For...
4
by: gane | last post by:
Hi, I am creating datagrid bound column dynamically and need to check if a datagrid column already exists?Is there a way to check this? thanks gane
2
by: Sharon | last post by:
I want put into my DataGrid different control types in the same column. For example: Column 1, row 0 ==> TextBox Column 1, row 2 ==> CheckBox Column 1, row 2 ==> ComboBox etc... As I see, I...
2
by: mark4asp | last post by:
This page is currently using a Repeater control to create a table with 6 columns. The first column has 2 ImageButton controls and a common header. How can I do this with a DataGrid ? I need...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.