473,788 Members | 2,811 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with empty cell value in GridView

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[0].Text.ToString( ) and try to compare it to String.Empty, I can't
because it contains "&nbsp". I really don't want to compare the value to
that so how can I retrieve an empty cell so that it is String.Empty.

Bill
Aug 6 '07 #1
3 3310
"Bill Gower" <bi*******@char ter.netwrote in message
news:u0******** ********@TK2MSF TNGP05.phx.gbl. ..
Ok that's fine. I won't make it more difficult then it is. :) But now I
do have a real problem. I am retrieving the 3rd row which happens to have
no value in the cell and it is actually containing the value from the
first row same cell. When the gridview is displayed it is an empty cell
but when I retrieve it by

GridView.Rows[index].Cells[0].Text.ToString( ).

It has the value of the cell from the first row.

What is happening here?
Difficult to tell without seeing your code but, if you do a View Source on
the page in question, you will see the HTML table rendered from the GridView
webcontrol - does that shed any light on it...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 6 '07 #2
I checked the source and rows 1 to 3 have an entry in the cell and rows 4
to 5 have &nbsp in the cell. When I step through the code and check the
value at the cell from row 4, it has the value from the cell in row 1.

Bill
"Mark Rae [MVP]" <ma**@markNOSPA Mrae.netwrote in message
news:OU******** ******@TK2MSFTN GP02.phx.gbl...
"Bill Gower" <bi*******@char ter.netwrote in message
news:u0******** ********@TK2MSF TNGP05.phx.gbl. ..
>Ok that's fine. I won't make it more difficult then it is. :) But now I
do have a real problem. I am retrieving the 3rd row which happens to
have no value in the cell and it is actually containing the value from
the first row same cell. When the gridview is displayed it is an empty
cell but when I retrieve it by

GridView.Row s[index].Cells[0].Text.ToString( ).

It has the value of the cell from the first row.

What is happening here?

Difficult to tell without seeing your code but, if you do a View Source on
the page in question, you will see the HTML table rendered from the
GridView webcontrol - does that shed any light on it...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 6 '07 #3
"Bill Gower" <bi*******@char ter.netwrote in message
news:%2******** *********@TK2MS FTNGP04.phx.gbl ...
>I checked the source and rows 1 to 3 have an entry in the cell and rows 4
to 5 have &nbsp in the cell. When I step through the code and check the
value at the cell from row 4, it has the value from the cell in row 1.
Please show the code you're using...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 7 '07 #4

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

Similar topics

5
8365
by: Mark Olbert | last post by:
I ran into a situation this morning where the RowUpdating event of a GridView kept insisting there were no entries in either the OldValues or NewValues dictionaries. The GridView is bound to a strongly-typed collection, derived from CollectionBase, through the control's datasource property at runtime. From some googling it appears that, at least in the release candidate for NET2 this was a known bug; only binding to DataSources lets those...
4
8336
by: Ken Wigle | last post by:
All, I would be very grateful for any help on this question. I have an application in asp.net 2.0 where I dynamically create a datatable and then bind that to a gridview. Unfortunately, the date column always shows the date and time while I just want the short date. I have tried applying a format string {0:d} but to no avail. I saw a lot of posts regarding the htmlencode property but I do not know how to turn that off for a...
1
3522
by: Martin | last post by:
Hi, I'm having a problem with a datagridview control when trying to read the value of an unbound checkbox cell. The code below works fine if I click on any text cell, bound or unbound, and also if I click on a data bound checkbox cell. But it fails with null reference exception if I try to read the value on an unbound cell.
1
27503
by: K B | last post by:
I would like to create a gridview as below: Project Name 1-1 1-2 1-3 1-4 1-5 1-6 Project 1 BLUE BLUE BLUE BLUE GREEN GREEN more projects I would like to fill the cell with a solid color based on the value of the cell (e.g., documents that are complete (blue) or not complete (green). In effect have a solid bar indicator going across each row. I know how to color the cell based on the value, but not the click...
14
91372
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 N-35 Mercedes if my user clicks row 2, I want to see Mercedes, How can I do that? I have a buttonClick event for my select button, I'm trying to pull the values using the DataKeyName, but I keep getting 'object reference...
3
15721
by: gnewsgroup | last post by:
I have a GridView which is bound to my database. The leftmost column of the GridView has a value of either 0 or 1, and I need to highlight the cell of column 3 if the leftmost column has a value of 0. After highlighting, I want the leftmost column to disappear. So, in the OnDataBound event handler, I call a method HighlightCells() which looks like this (code from my memory):
2
8827
by: Bart | last post by:
Hi, i need to check wether a cell of a gridview is empty or not. I did this: Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged Dim log1 As String log1 = GridView1.SelectedRow.Cells(1).Text .....
1
4520
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 checkbox is checked, all of the rows in the GridView are checked, if this checkbox is unchecked, all of the rows in the GridView are unchecked. This checking/unchecking of the checkboxes in the GridView is handled by a JavaScript method: function...
1
1850
nitindel
by: nitindel | last post by:
Hi All, Please tell me any good site for Gridview control.(not for datagrid). I am facing error in fetching the values of the Bound columns in the gridview: lease tell me how should i fetch the value..of a bound column..?? Below is the code.:
0
9656
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...
1
10110
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
9967
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
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...
1
7517
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
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
5398
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...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3670
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.