Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > how to check if cell of gridview is empty?

Reply
Thread Tools

how to check if cell of gridview is empty?

 
 
Bart
Guest
Posts: n/a
 
      02-08-2008
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
.....

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


 
Reply With Quote
 
 
 
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      02-08-2008
"Bart" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> 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

 
Reply With Quote
 
 
 
 
Bart
Guest
Posts: n/a
 
      02-08-2008
Thanks

"Mark Rae [MVP]" <(E-Mail Removed)> schreef in bericht
news:%(E-Mail Removed)...
> "Bart" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
GridView Hierarchical View - Gridview in Gridview =?Utf-8?B?bWdvbnphbGVzMw==?= ASP .Net 1 05-09-2006 06:48 PM
How to set and highlight text in JTable cell on selection and/or invoke cell editor directly. news.rcn.com Java 1 07-12-2004 10:22 PM
How do I have a table cell fetch another page to display within the cell? Phillip Roncoroni HTML 14 04-05-2004 05:58 PM
multilink cell phones multilinking shotgun 2 cell phones Calvin Cisco 1 11-07-2003 02:20 PM



Advertisments