Groups | Blog | Home
all groups > asp.net datagrid control > december 2004 >

asp.net datagrid control : Get the datafield of a column in datagrid


et
12/27/2004 5:19:20 PM
How can I programmatically retrieve the name of the datafield of a datagrid
column, while in the Datagrid1_UpdateCommand event.

Eliyahu Goldin
12/28/2004 11:20:31 AM
For bound non-autogenerated columns you can use property DataField.
Autogenerated columns don't get into Columns collection. There is still a
way of finding the field name. In ItemCreated event handler get the text
inside every cell of the very first item. That will be the column header
which is the field name for autogenerated columns.

Eliyahu

[quoted text, click to view]

Rock
12/30/2004 9:42:12 AM
[quoted text, click to view]

Where is this property??? I have tried dg.datafield, dg.columns.datafield,
dg.Columns(1).datafield....

My datagrid does not have autogenerated columns.


[quoted text, click to view]

Eliyahu Goldin
1/2/2005 10:41:26 AM
in c#:

dg.Columns[1].DataField;

provided Columns[1] is a BoundColumn.

Look up the help.

Eliyahu

[quoted text, click to view]

AddThis Social Bookmark Button