469,648 Members | 1,192 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,648 developers. It's quick & easy.

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_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
Feb 8 '08 #1
2 8403
"Bart" <b@b.dwrote in message
news:et**************@TK2MSFTNGP05.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**@markNOSPAMrae.netschreef in bericht
news:%2***************@TK2MSFTNGP02.phx.gbl...
"Bart" <b@b.dwrote in message
news:et**************@TK2MSFTNGP05.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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Jon S via DotNetMonster.com | last post: by
11 posts views Thread by Jo | last post: by
2 posts views Thread by Chris Davoli | last post: by
3 posts views Thread by Bill Gower | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.