473,396 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
3 1858
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
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
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Brian Greiwe | last post by:
I posted this in the datagrid forum but got no bites, so I thought I'd post it here as well for some help.... I've created a datagrid with 1 edititemtemplate column. When the user clicks...
1
by: Alex | last post by:
Hi all... I have a DataGrid bound to a DataTable. My DataTable gets updated programmatically as it contains the status of a number of worker threads. Each "main" worker thread launches a...
2
by: Wendy Spray | last post by:
Hi I have an xml document that has been created from an excel spreadsheet. In the s/s there are some empty cells however these are not captured in the xml file. All that is added is for the cell...
7
by: Matthew Wieder | last post by:
Hi - I have a datagrid that has a black header and the rows alternate white and gray. The problem is that until items are added to the grid, the grid appears as a large black rectangle, which is...
4
by: momo | last post by:
Hello all, I need help with this. I have a datagrid (dg1) with checkboxes and I want when some rows are selected to populate another datagrid (dg2) with the selected rows from (dg1). Thanks ...
10
by: Terry Olsen | last post by:
I've got a datagrid set up to display data. I've also got an Edit,Update,Cancel column set up to allow editing of data. I've got a DropDownList (ID="ddl3")in the EditItemTemplate for a certain...
7
by: Neo Geshel | last post by:
Greetings. I have a serious problem. I have multiple sets of tables, several of which are chained more than two tables deep. That is, I have a parent, a child, and a great-grandchild table. ...
1
by: keith.walter | last post by:
My first asp.net app is almost "done" and I am stuck. Here is my situation: I have a "mother" page add_customer.aspx and a"child" user control add_group.ascx. On the mother page is an "add...
1
by: Ahmed Yasser | last post by:
Hi all, i have a problem with the datagridview sorting, the problem is a bit complicated so i hope i can describe in the following steps: 1. i have a datagridview with two columns...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.