473,802 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Recept ions.Items
Response.Write( CType( vDgi_GridItem.C ells(10).Text.t rim.length ,
string) )
If vDgi_GridItem.C ells(10).Text.t rim.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 1880
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**********@j oseph.NOSPAM.co .uk> wrote in message
news:cs******** ***********@new s.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_Recept ions.Items
Response.Write( CType( vDgi_GridItem.C ells(10).Text.t rim.length ,
string) )
If vDgi_GridItem.C ells(10).Text.t rim.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.C ells(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.co m> wrote in message
news:%2******** **********@TK2M SFTNGP12.phx.gb l...
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**********@j oseph.NOSPAM.co .uk> wrote in message
news:cs******** ***********@new s.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_Recept ions.Items
Response.Write( CType( vDgi_GridItem.C ells(10).Text.t rim.length ,
string) )
If vDgi_GridItem.C ells(10).Text.t rim.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
2687
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 edit, it spans the entire width of the datagrid (removing the other cells). This column has several controls in it (text boxes, radiobuttons, and a dropdownlist). Also, on the itemdatabound, I am adding another row to the datagrid (above the...
1
1521
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 number "child" threads, so displaying the status of these in a DataGrid is ideal - one row for each "main" thread, one column for each "child" thread. However, some of these threads take a while to update their status, so I'd
2
3791
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 after where the empty cell should be, it has an extra attribute: "ss:Index="6", where it is the 6th cell in the row, and cell 5 had no entry. I'm wanting to pick out a particular cell from a particular column however just iterating through the...
7
4677
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 quite ugly. The black area is larger then it is once an item is added. How can I solve this problem either by: A) Having only the header black and the rest of the empty block white or gray (preffered solution) B) Having the color gray or white...
4
353
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 Momo
10
1909
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 column that I need to populate while in Edit Mode. Two questions: Is there a way to directly use another DropDownList as a DataSource? If so how? I'm using the following code to try to populate the DropDownList, but
7
2017
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. Currently, I am allowing the parent to be edited by itself. In order to get to a child table, a user needs to select a specific parent table ID. I have set this up using panels, and putting a drop-down list in the first panel, with its contents...
1
2642
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 group" button that makes the the panel inwhich the add_customer control resides VISIBLE=True. On the control, the user can edit the list of groups, or add a new one. After the edit is complete I want to make the panel again VISIBLE=False, as well as...
1
2184
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 (LoginName,UserName) 2. the datagridview sorting is set to automatic, so when i click on the column header is sorts well. 3. i put in an event handler for the CellEndEdit Event, so whenever the user of the program changes the content of a cell in the LoginName...
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10304
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10285
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.