Get the datafield of a column in datagrid

E

et

How can I programmatically retrieve the name of the datafield of a datagrid
column, while in the Datagrid1_UpdateCommand event.
 
E

Eliyahu Goldin

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
 
R

Rock

For bound non-autogenerated columns you can use property DataField.

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

My datagrid does not have autogenerated columns.
 
E

Eliyahu Goldin

in c#:

dg.Columns[1].DataField;

provided Columns[1] is a BoundColumn.

Look up the help.

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,436
Messages
2,571,696
Members
48,796
Latest member
Greg L.
Top