473,405 Members | 2,287 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,405 software developers and data experts.

How to get DataField value of a cell

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 = ???
}
Nov 19 '05 #1
3 6158
What do you mean by datafield value?

Eliyahu

"Dinçer" <dincer"AT"o2.pl> wrote in message
news:OM****************@tk2msftngp13.phx.gbl...
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 = ???
}

Nov 19 '05 #2
"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" <re*************@monarchmed.com> wrote in message
news:u9**************@TK2MSFTNGP15.phx.gbl...
What do you mean by datafield value?

Eliyahu

"Dinçer" <dincer"AT"o2.pl> wrote in message
news:OM****************@tk2msftngp13.phx.gbl...
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 = ???
}


Nov 19 '05 #3
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" <dincer"AT"o2.pl> wrote in message
news:OJ**************@TK2MSFTNGP11.phx.gbl...
"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" <re*************@monarchmed.com> wrote in message
news:u9**************@TK2MSFTNGP15.phx.gbl...
What do you mean by datafield value?

Eliyahu

"Dinçer" <dincer"AT"o2.pl> wrote in message
news:OM****************@tk2msftngp13.phx.gbl...
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 = ???
}



Nov 19 '05 #4

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

Similar topics

0
by: richard | last post by:
i want to generate dynemic update sql. for this i need the database field. (i need the <asp:BoundColumn DataField value ) how can i retrieve it in the datagrid_UpdateCommand(object source,...
0
by: Blibo Baggins | last post by:
How do you get the "Datafield" property of data that's in a Template Column of a Grid? I am using editable Datagrids with Template Columns. When using Boundcolumns, I just used: ColName =...
1
by: Morten Snedker | last post by:
How do I the value of a cell in a datagridview, before it is updated? I wish to validate the "visible" value, not the actual value (cell/row hasn't been updated yet). Thanks in advance. ...
1
by: paolo.ponzano | last post by:
Hello everybody, I'm trying (till now with no success) to access at DataField property of a DataGrid. I explain you my situation. I've a DataGrid, called DataGrid1 that's binded to an...
1
by: cider123 | last post by:
Is there a way to add a Datafield value to a PostBack URL in another column of the same row ? In my case I have this hidden value of SystemID: <Columns> <asp:BoundField DataField="SystemID"...
1
by: PawelR | last post by:
Hi Group, In my application I have DataTable which is displayed in DataGridView via DataView: DataView myView = new DataView(myTable); myDataGridView.DataSource = myView; One column im...
0
by: ajanu81 | last post by:
hi all, i am new to this forum. i am using a windows application using C#. I am using a datagridview to display contents of a xml file. say i have a xml file like this. <xml version="1.0"...
2
by: HenrikRinder | last post by:
This is a silly question, but now I have spent hours trying to figure it out. Thus, asking this forum: Our application GUI has a .NET PropertyGrid. Our customers don't find it intuitive to...
0
by: news.microsoft.com | last post by:
Hello- I'm having a dickens of a time trying to set the value on a DataGridViewComboBoxColumn. I actually have two DataGridViewComboBoxColumns in my datagrid view. First, I'm setting up the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.