473,698 Members | 2,051 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid - reading the cell content

Hi,

I have a datagrid which binds to a datareader

dgXXXXX.DataSou rce = rdr;
dgXXXXX.DataBin d();

On dgXXXXX_EditCom mand I can read the value of the selected row(
e.Item.ItemInde x) which works. How can I read the contents of that cell. I
have the following code which doesn't work.
dgXXXXX.EditIte mIndex = e.Item.ItemInde x;

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

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

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

Nov 18 '05 #1
2 2189
Once you've identified the cell you want, you need to identify the control
that is in that cell that holds the data. The cell most likely contains a
label and it is the label that contains the text. Try:

e.Item.ItemInde x.Cells[2].FindControl[controlName].Text
"Maziar Aflatoun" <ma***@rogers.c om> wrote in message
news:1U******** **********@news 04.bloor.is.net .cable.rogers.c om...
Hi,

I have a datagrid which binds to a datareader

dgXXXXX.DataSou rce = rdr;
dgXXXXX.DataBin d();

On dgXXXXX_EditCom mand I can read the value of the selected row(
e.Item.ItemInde x) which works. How can I read the contents of that cell. I
have the following code which doesn't work.
dgXXXXX.EditIte mIndex = e.Item.ItemInde x;

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

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

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

Nov 18 '05 #2
Maziar:
It might be easier if you put the value in a hidden form field <input
type="hidden" id="filename" runat="Server" value='<%#
DataBinder.Eval (Container.Data Item, "filename") %>' /> and use
e.Item.FindCont rol("filename") to get a reference to field in onEditCommand.

Karl

"Maziar Aflatoun" <ma***@rogers.c om> wrote in message
news:1U******** **********@news 04.bloor.is.net .cable.rogers.c om...
Hi,

I have a datagrid which binds to a datareader

dgXXXXX.DataSou rce = rdr;
dgXXXXX.DataBin d();

On dgXXXXX_EditCom mand I can read the value of the selected row(
e.Item.ItemInde x) which works. How can I read the contents of that cell. I
have the following code which doesn't work.
dgXXXXX.EditIte mIndex = e.Item.ItemInde x;

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

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

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

Nov 18 '05 #3

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

Similar topics

7
7687
by: Billy Jacobs | last post by:
I am using a datagrid to display some data. I need to create 2 header rows for this grid with columns of varying spans. In html it would be the following. <Table> <tr> <td colspan=8>Official Impact Summary</td> </tr> <tr> <td colspan=2></td>
1
4638
by: VM | last post by:
Is it possible for the bound data in a web datagrid to be displayed in links? The grid will show the client's first name and last name and, when the user clicks on the first or last name, I want to get the cell the user clicked (thus getting the client he chose), and take the user to another separate page that will show that client's complete information. It doesn't really have to be like that (there could be another extra column - as a...
0
1520
by: elime | last post by:
Hi all I have a strange behaving on some PC with my DataGrid. It only occurs on some PC, on others it works perfectly fine. ->(same ..net version installed) it's very confusing. starting position: I click with the mouse into a cell of the DataGrid, the cell gets active (gray) and marks the cell-content.
2
3177
by: Daniel Walzenbach | last post by:
Hi, I created an ASP.NET Datagrid where a single row can be selected by clicking anywhere on the row (according to http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchTopQuestionsAboutASPNETDataGridServerControl.asp, Selecting Rows by Clicking Anywhere). Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, _ ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
5
3500
by: Brian Henry | last post by:
I have a messaging application that has a data grid with information like an email list would have (from, subject, time sent, size) but the subject could be very long in theory, and then it would word wrap.. the subject is a variable width column (resizes to fit space) while the others are fixed size... the problem is that i dont want the text to ever word wrap.. but truncate the visible subject to match the current cell width... (kinda...
1
6716
by: Tracey | last post by:
Hi, there My application requires to display multiline text in the cell of datagrid. I set the preferredheight of datagrid's tablsstyle, however, it is fixed. For text longer than that, the rest of text is cut missing. Can someone tell me how to do that? thanks.
2
2847
by: Peter | last post by:
ASP.NET 2003 In the DataGrid how do I select current cell value in the dropdown box when I click on the edit link, currently when I click on the edit link in the DataGrid the dropdown box appears in the cell, but allways the first item in the dropdown box is shown not the current cell value? How do I make the current value in the cell automaticaly be selected in the dropdown box.
7
3221
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 column need to be a date picker field. I know things will be easier with ASPX datagrid.
2
6588
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click in the child datagrid and then go to the combobox and choose another vendor. When the new vendor is loaded nothing shows in the datagrid but the itemsource shows the info is there. Know if I click on the child cell and then click back on the...
0
8671
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8598
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9152
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9016
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8887
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7709
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5858
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4360
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2321
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.