How to get DataField value of a cell

  • Thread starter Thread starter Dinçer
  • Start date Start date
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 = ???


}
 
"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 = ???


}
 
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 = ???


}
 
Back
Top