473,773 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to check if cell of gridview is empty?

Hi,

i need to check wether a cell of a gridview is empty or not. I did this:

Protected Sub GridView1_Selec tedIndexChanged (ByVal sender As Object, ByVal e
As System.EventArg s) Handles GridView1.Selec tedIndexChanged
Dim log1 As String
log1 = GridView1.Selec tedRow.Cells(1) .Text
.....

If log1 = "" Then
Response.Write( "empty")
else
Response.Write( log1)
end if
....
When log1 contains data, i get it in the response.write, but when the field
in the sql-database contains NULL or is empty (e.g. by a previous update
operation), i don't get the expected 'empty'. So log1 = "" is considered
as false.

I checked the length with this line: response.write( log1.length)

This gives the right length when data is present, but gives 6 when it's NULL
or empty !!

Is that the default length of the empty cell in a gridview? How to test when
that cell is empty? (i also tried with IsDbNull but doesn't work either).

Thanks
Bart
Feb 8 '08 #1
2 8826
"Bart" <b@b.dwrote in message
news:et******** ******@TK2MSFTN GP05.phx.gbl...
How to test when that cell is empty?
A quick View Source would have given you the answer...

When a bound GridView cell contains no data, ASP.NET fills it with &nbsp;

Hence the length of 6...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Feb 8 '08 #2
Thanks

"Mark Rae [MVP]" <ma**@markNOSPA Mrae.netschreef in bericht
news:%2******** *******@TK2MSFT NGP02.phx.gbl.. .
"Bart" <b@b.dwrote in message
news:et******** ******@TK2MSFTN GP05.phx.gbl...
>How to test when that cell is empty?

A quick View Source would have given you the answer...

When a bound GridView cell contains no data, ASP.NET fills it with &nbsp;

Hence the length of 6...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Feb 8 '08 #3

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

Similar topics

1
9388
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 in the dataset is empty. The cells that are empty, in the gridview control, I would like to have the value of 0 (zero) inserted. Is there a default cell value property or something similar for the asp.net gridview control. So if no data is...
11
15011
by: Jo | last post by:
Hi all, I have a gridview displaying a dataset and some buttons. When a certain cell of this datasetrow is empty, I want a button in that row to be visible, otherwise no button should be shown in that row. I'm trying to make this work all day, but it's not going to work. I tried this in the rowCreated event. I am able to find the right row and cell in this row (as a datarow), but now the right gridview
2
3598
by: Chris Davoli | last post by:
How do you enable a check box in the GridView. I selected Checkbox Field in the Columns of the GridView, and the check box shows up in the Grid view, but it is disabled. How do I enable it so I can check/uncheck it. Also, what event do I use to check it for a value? Any articles out there? -- Chris Davoli
3
1745
gchq
by: gchq | last post by:
Using both static data and data from some GridView cells I am attempting to calculate a result in a Template Cell - but to no avail! The value for TextBox1 is brought in on the page_load event and I'm attempting the balance of the calculation uisng the ItemDataBound event :- Protected Sub GridView1_ItemDataBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs) If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType...
1
27502
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...
3
3309
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 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
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...
0
1272
by: S_K | last post by:
Hi, I have an editible GridView that I can read the contents of each cell of the edit row as follows: int iEditIndex = GridView2.EditIndex; string strName = GridView2.Rows.Cells.Text; This works fine with the HTML of the cell set up as follows (note the readonly="True"):
4
5862
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 know if it is possible to make such focus? Thanks! Bill
0
9621
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
10106
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...
0
9914
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
8937
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
7463
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
6717
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
5355
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
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3610
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.