By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,816 Members | 2,151 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,816 IT Pros & Developers. It's quick & easy.

Can you help with detecting empty cells in a datagrid ??

P: n/a
Hi,

I'm trying detect an empty cell in a datagrid when the content is posted
back to the server.

My code is...

Dim vDgi_GridItem As DataGridItem
For Each vDgi_GridItem In oASP_Dgd_Receptions.Items
Response.Write( CType( vDgi_GridItem.Cells(10).Text.trim.length ,
string) )
If vDgi_GridItem.Cells(10).Text.trim.length > 0 then
...OK...
Else
...Not OK...
End If
Next

When the cell contains text, the length works fine, but if the cell is empty
(bound to a field with an empty string) it always returns a length of 6
characters.

Any ideas why ?? Why is the "trim" not emptying these space or whatever is
in there.

Regards

Simon
Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
6 characters is the length of string " " (non-breaking space}. That it
what datagrids have in empty cells.Check cell text on this value to see if
it is empty.

Eliyahu

"Simon Prince" <si**********@joseph.NOSPAM.co.uk> wrote in message
news:cs*******************@news.demon.co.uk...
Hi,

I'm trying detect an empty cell in a datagrid when the content is posted
back to the server.

My code is...

Dim vDgi_GridItem As DataGridItem
For Each vDgi_GridItem In oASP_Dgd_Receptions.Items
Response.Write( CType( vDgi_GridItem.Cells(10).Text.trim.length ,
string) )
If vDgi_GridItem.Cells(10).Text.trim.length > 0 then
...OK...
Else
...Not OK...
End If
Next

When the cell contains text, the length works fine, but if the cell is empty (bound to a field with an empty string) it always returns a length of 6
characters.

Any ideas why ?? Why is the "trim" not emptying these space or whatever is in there.

Regards

Simon

Nov 19 '05 #2

P: n/a
Fantastic you got it !!!

If I test the content of the Cell with ... If vDgi_GridItem.Cells(10).Text =
"&nbsp;" it returns true. I was trying to show the content of the text but
of course it was rendering as HTML and so not showing.

I did read somewhere about the NULLTEXT property of datacloumn, that I may
be able to control what it does with Null values when showinng in data
grids.

Regards

Simon

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl...
6 characters is the length of string "&nbsp;" (non-breaking space}. That it
what datagrids have in empty cells.Check cell text on this value to see if
it is empty.

Eliyahu

"Simon Prince" <si**********@joseph.NOSPAM.co.uk> wrote in message
news:cs*******************@news.demon.co.uk...
Hi,

I'm trying detect an empty cell in a datagrid when the content is posted
back to the server.

My code is...

Dim vDgi_GridItem As DataGridItem
For Each vDgi_GridItem In oASP_Dgd_Receptions.Items
Response.Write( CType( vDgi_GridItem.Cells(10).Text.trim.length ,
string) )
If vDgi_GridItem.Cells(10).Text.trim.length > 0 then
...OK...
Else
...Not OK...
End If
Next

When the cell contains text, the length works fine, but if the cell is

empty
(bound to a field with an empty string) it always returns a length of 6
characters.

Any ideas why ?? Why is the "trim" not emptying these space or whatever

is
in there.

Regards

Simon


Nov 19 '05 #3

P: n/a
> I did read somewhere about the NULLTEXT property of datacloumn, that I may
be able to control what it does with Null values when showinng in data
grids.


Don't bother. Even if you set in your code empty string values to "", they
will be still fitted with "&nbsp;".

Eliyahu
Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.