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

Datagrid cell values

Hi,

I have a datagrid which binds to a datareader

dgXXXXX.DataSource = rdr;
dgXXXXX.DataBind();

On dgXXXXX_EditCommand I can read the value of the selected row(
e.Item.ItemIndex) which works. How can I read the contents of that cell. I
have the following code which doesn't work.
dgXXXXX.EditItemIndex = e.Item.ItemIndex;

Filename = dgXXXXX.Items[e.Item.ItemIndex].Cells[2].Text;

Response.Write("Filename:" + Filename);

Can't I grab a cell content of a datagrid?
Thank you
Maziar A.
Jul 21 '05 #1
1 1540

"Maziar Aflatoun" <ma***@rogers.com> wrote in message
news:kT******************@news04.bloor.is.net.cabl e.rogers.com...
Hi,

I have a datagrid which binds to a datareader

dgXXXXX.DataSource = rdr;
dgXXXXX.DataBind();

On dgXXXXX_EditCommand I can read the value of the selected row(
e.Item.ItemIndex) which works. How can I read the contents of that cell. I
have the following code which doesn't work.
dgXXXXX.EditItemIndex = e.Item.ItemIndex;

Filename = dgXXXXX.Items[e.Item.ItemIndex].Cells[2].Text;

Response.Write("Filename:" + Filename);

Can't I grab a cell content of a datagrid?
Thank you
Maziar A.

It depends on how your datatable is set up but here are some possibilities
which you can try. Obviously the cell number is based on your table.

e.item.cells(3).text (if your datacolumns are automatic)

Directcast(e.item.controls(3),tablecell).text (if your data is in an item
template)
DirectCast(e.Item.Cells(3).controls(0),textbox).te xt (if you data in in an
edit textbox, .net generates a textbox inside the cell in edit mode and the
control index always be 0)

You can also build a datakey with a separator add it to your column
collection and use something like this
split(DirectCast(sender,datagrid).datakeys(e.item. itemindex).tostring(),";x"
)
Hope this gives you something to go on.
Mike
Jul 21 '05 #2

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

Similar topics

3
by: Dmitry Akselrod | last post by:
Hi, I am using a standard .NET 1.0 Datagrid. Actually, I am using two, bound to a master-detail relationship. Both DataGrids are bound to a datasource. I have the MSDN version of the...
2
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell...
9
by: Morten | last post by:
Hi! I have a problem displaying some values in a datagrid. I have an array that consists of a number of objects. Each object has 2 properties: Name and a list of web addresses. (e.g: Name:...
7
by: TT (Tom Tempelaere) | last post by:
Hi there, I'm struggling to get the right event. I want to be notified of a change in a cell in a DataGrid made by a user. I need following information about the change: * the row index * the...
2
by: itgMan | last post by:
hello friends, i have a question about datagrid, i have binded a datagrid with a datatable from values that came from a comma seperated values (.CSV) file i have created textboxes in all...
13
by: Lyners | last post by:
I have a web page writen in ASP.NET that contains some javascript so that when a user presses a button, or edits a certain field in a datagrid, another cell in the datagrid is filled with a value....
7
by: julian.tklim | last post by:
Hi, I need to build an editable Datagrid with add & delete buttons on each row using javascript. DataGrid need not be pre-populated with values. To make the thing complicated, one of the...
9
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the...
2
by: Iain | last post by:
Hi All Using Delphi 2006 developer - C# Project I have the following 2 event handlers for the datagrid - see botton of page Both events will fire off correctly but i have a problem collecting...
4
by: _MC_ | last post by:
Hi, I'm unable to access values in my Datagrid. Datagrid thinks it hase only 1 Cell. So here it is: The Datagrid is binded in PageLoad, AutoGenerateColumns is false, Columns are added on...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.