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

S

Simon Prince

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
 
E

Eliyahu Goldin

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
 
S

Simon Prince

Fantastic you got it !!!

If I test the content of the Cell with ... If vDgi_GridItem.Cells(10).Text =
" " 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
 
E

Eliyahu Goldin

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 " ".

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top