How to get DataField value of a cell

D

Dinçer

Hi all!

I want to get the datafield value of a cell in a datagrid item. How can I do
this?
I have a for loop (as below) and I am able to get the data in the cell, but
not the datafield value.

Regards.

foreach(DataGridItem dataGridItem in MyDataGrid)

{

string cellText = dataGridItem.Cells[0].Text;

//string cellValue = ???


}
 
D

Dinçer

"dataGridItem.Cells[0].Text" gives me the value of the cell; for example :
Bill
"dataGridItem.Cells[1].Text" gives me the value of the second cell; for
example : Gates
These are OK.

What I need is the field name of these values in the database; for example:
"name" and "surname" for the data above

Is there anyway to get these values?


Eliyahu Goldin said:
What do you mean by datafield value?

Eliyahu

Dinçer said:
Hi all!

I want to get the datafield value of a cell in a datagrid item. How can
I
do
this?
I have a for loop (as below) and I am able to get the data in the cell, but
not the datafield value.

Regards.

foreach(DataGridItem dataGridItem in MyDataGrid)

{

string cellText = dataGridItem.Cells[0].Text;

//string cellValue = ???


}
 
E

Eliyahu Goldin

If your column is a BoundColumn, and if it is not autogenerated, you can get
the field name as

(myGrid.Columns[0] as BoundColumn).DataField

If it is autogenerated, you can get the field names in ItemCreated event for
the grid column headers. The cell text will be set to the column header,
which should be the same as data field name.

Eliyahu

Dinçer said:
"dataGridItem.Cells[0].Text" gives me the value of the cell; for example :
Bill
"dataGridItem.Cells[1].Text" gives me the value of the second cell; for
example : Gates
These are OK.

What I need is the field name of these values in the database; for example:
"name" and "surname" for the data above

Is there anyway to get these values?


Eliyahu Goldin said:
What do you mean by datafield value?

Eliyahu
can
I
do
this?
I have a for loop (as below) and I am able to get the data in the
cell,
but
not the datafield value.

Regards.

foreach(DataGridItem dataGridItem in MyDataGrid)

{

string cellText = dataGridItem.Cells[0].Text;

//string cellValue = ???


}
 

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
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top