473,387 Members | 1,464 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,387 software developers and data experts.

assigning values to cells on itemdatabound

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
Jun 1 '06 #1
3 1854
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" wrote:
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

Jun 1 '06 #2
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 [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:BD**********************************@microsof t.com...
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" wrote:
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

Jun 1 '06 #3
Any ideas on how to assign value to a datagrid cell referencing the column
name?
"gane" <ga**@sdff.com> wrote in message
news:e4**************@TK2MSFTNGP05.phx.gbl...
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 [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:BD**********************************@microsof t.com...
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" wrote:
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


Jun 5 '06 #4

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

Similar topics

2
by: Craig Buchanan | last post by:
Is there a way to add a row to a datagrid during the ItemDataBound event? I would like to add a 'header' row before the start of a group of rows. Thanks, Craig Buchanan
4
by: Vik | last post by:
How can I display the lookup values in a datagrid? E.g., the datagrid displays a table that contains a ProductID field. I want to display a Product description from a Product table in that...
0
by: Newasps | last post by:
Hi guys, I have a problem with UpdateCommand Event. In tihs event Ä°'m creating required controls to get that controls' values and also get them. But when I try to get updated values I'm getting the...
0
by: Ozer | last post by:
Hi guys, I need some help. In my datagrid's updatecommand event i'm trying to get textboxes values and also do it. But when i update the values in textboxes and fire the event, I can't get the...
1
by: David Tilman | last post by:
I have an ASP .NET web application that changes datagrid cells in the ItemDataBound event, like changing the Columnspan of a cell to 2 and deleting the adjacent cell, so that I have two cells...
4
by: velu | last post by:
I have created a table MSSQL that contain values and published into Datagrid. The table is typically like this.. Tbl Article Rating Count 1 3 3 2 0 0 3 2 1 4 4 5
1
by: Mike G | last post by:
I have a datagrid that is editable by the user. Some of the columns are readonly and others can be edited. I have one column that I need to be able to make readonly based on the values of other...
2
by: =?Utf-8?B?RXVnZW5l?= | last post by:
Hi, I use a datagrid with asp:templatecolumn, and handles the datagrid's ItemDataBound event, whereby I assign a value to this asp:templatecolumn text. e.Item.Cells.Text = e.Item.Cells.Text +...
2
by: Blacky | last post by:
Hi, I am using c# asp.net application.I have datagrid which binds column dynamically and i make certain columns say visibility to false in my itemdatabound event EMPID AS E.ITEM.CELLS.VISIBLE =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.