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

Getting value of a GridView cell

Hi All,

Can anyone help me out here?

I am trying to get the value of a GV cell, code is below (Obviously
not useful - But this is what I have ended up with during my testing).

I have bound columns and template columns - e.Row.Cells[i].text() is
always an empty string!

Cheers!
Simon.

protected void GVContacts_RowCreated(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{

for (int i = 0; i < e.Row.Cells.Count; i++)
{
this.Label1.Text += e.Row.Cells[i].text();
}
}
}

Nov 14 '07 #1
4 19131
On Nov 14, 1:48 pm, TisMe <simonmhar...@googlemail.comwrote:
Hi All,

Can anyone help me out here?

I am trying to get the value of a GV cell, code is below (Obviously
not useful - But this is what I have ended up with during my testing).

I have bound columns and template columns - e.Row.Cells[i].text() is
always an empty string!

Cheers!
Simon.

protected void GVContacts_RowCreated(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{

for (int i = 0; i < e.Row.Cells.Count; i++)
{
this.Label1.Text += e.Row.Cells[i].text();
}
}
}
Weird that it's empty and not throwing an exception or even a
compilation error. text() doesn't exist, it should be Text. It's a
property not a method. So...

this.Label1.Text += e.Row.Cells[i].Text;

Nov 14 '07 #2
On Wed, 14 Nov 2007 13:48:04 -0800, TisMe
<si**********@googlemail.comwrote:
>Hi All,

Can anyone help me out here?

I am trying to get the value of a GV cell, code is below (Obviously
not useful - But this is what I have ended up with during my testing).

I have bound columns and template columns - e.Row.Cells[i].text() is
always an empty string!

Cheers!
Simon.

protected void GVContacts_RowCreated(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{

for (int i = 0; i < e.Row.Cells.Count; i++)
{
this.Label1.Text += e.Row.Cells[i].text();
}
}
}
Hi,
You have the code in the Row created handler. Is it possible that the
data is not bound yet?
Have you tried the RowDataboundEvent?
Bob
Nov 15 '07 #3
TisMe wrote:
Hi All,

Can anyone help me out here?

I am trying to get the value of a GV cell, code is below (Obviously
not useful - But this is what I have ended up with during my testing).

I have bound columns and template columns - e.Row.Cells[i].text() is
always an empty string!
That's because DataGridViewCells store their data in the Value property.
What you're looking for is:

e.Row.Cells[i].Value.ToString();
Chris.
Nov 15 '07 #4
That's because DataGridViewCells store their data in the Value property.
What you're looking for is:

e.Row.Cells[i].Value.ToString();
Chris, thanks but there doesnt seem to be a value property!?...

Compiler Error Message: CS0117: 'System.Web.UI.WebControls.TableCell'
does not contain a definition for 'Value'
Nov 16 '07 #5

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

Similar topics

4
by: Neil | last post by:
I have a gridview which is being populated with no problems. I want to be able to reference the data from the cells in the row but having followed an example on MSDN cannot get any data to be...
1
by: Jon S via DotNetMonster.com | last post by:
HI all, I'm returning a dataset to a gridview control. When the gridview asp.net control is populated from the returning dataset some of the cells remain empty. This is expected as some data...
8
by: graphicsxp | last post by:
Hi, How can I get the value of a cell that belongs to a hidden column of gridview ? Here's how I normally access the value of a cell, but it doesn't work if the column is invisible: Code :...
2
by: Mike P | last post by:
I know how to get at different controls in a gridview using FindControl, and I can change the forecolor or backcolor of the control in the RowDataBound event (see below). But what I want to do is...
4
by: pvong | last post by:
Hi, I'm a newbie and I'm looking for some help. I'm programming in VB.Net. I have a simple gridview and when the user hits the Edit link, the gridview changes to edit mode. I replaced the...
3
by: Bill Gower | last post by:
I have an cell which contains a field member which is filled with String.Empty. When I retrieve the value in the cell with Cells.Text.ToString() and try to compare it to String.Empty, I can't...
14
by: Mike | last post by:
I have a gridview that has a button in the last cell of each row. I want to get the text from cell 1 for that row the button was clicked on. So if my gridview looks like this: N-12 BMW ...
3
by: David C | last post by:
I have a GridView and when the SelectedIndexChange occurs I want to put the value of a BoundField into a TextBox (txtPropertyID) on the page. Below is the code I am using but it is not getting the...
1
Frinavale
by: Frinavale | last post by:
I'm working on an ASP.NET application using VB.NET for server side code. I have a GridView listing a bunch of stuff. Above the GridView I have a checkbox named "ChkBx_SelectAll". If this...
4
by: foolmelon | last post by:
Before AJAX, we were able to focus a cell in a gridview during a fullpage postback. After putting the gridview inside an UpdatePanel, we cannot focus a cell in this gridview anymore. Does anybody...
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...
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
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
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
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...
0
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...

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.