assigning values to cells on itemdatabound

G

gane

Hi,

I would like to assign a value to a datagrid item using the column name
instead of using something like e.item.cell[1].text in itemdatabound

eg:
DataRowView rv = (DataRowView)e.Item.DataItem;
string strLocation = Convert.ToString(rv.Row["locationptr"].ToString())

I used dataitem to fetch, but i donno how to assign some value.

Thanks
Gane
 
G

gane

Thanks.
I have my column names stored in web.config as key/value pairs.
column names might be added or removed from web.config files.
I would appreciate it, if you can show me a small eg. on how to acheive this
?

Peter Bromberg said:
You could create an enum that maps the column names to ordinal position.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




gane said:
Hi,

I would like to assign a value to a datagrid item using the column name
instead of using something like e.item.cell[1].text in itemdatabound

eg:
DataRowView rv = (DataRowView)e.Item.DataItem;
string strLocation = Convert.ToString(rv.Row["locationptr"].ToString())

I used dataitem to fetch, but i donno how to assign some value.

Thanks
Gane
 
G

gane

Any ideas on how to assign value to a datagrid cell referencing the column
name?
gane said:
Thanks.
I have my column names stored in web.config as key/value pairs.
column names might be added or removed from web.config files.
I would appreciate it, if you can show me a small eg. on how to acheive
this ?

Peter Bromberg said:
You could create an enum that maps the column names to ordinal position.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




gane said:
Hi,

I would like to assign a value to a datagrid item using the column name
instead of using something like e.item.cell[1].text in itemdatabound

eg:
DataRowView rv = (DataRowView)e.Item.DataItem;
string strLocation = Convert.ToString(rv.Row["locationptr"].ToString())

I used dataitem to fetch, but i donno how to assign some value.

Thanks
Gane
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top