473,545 Members | 2,012 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Selec tedIndexChanged (ByVal sender As Object, ByVal e
As System.EventArg s) Handles GridView1.Selec tedIndexChanged
Dim log1 As String
log1 = GridView1.Selec tedRow.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 8807
"Bart" <b@b.dwrote in message
news:et******** ******@TK2MSFTN GP05.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**@markNOSPA Mrae.netschreef in bericht
news:%2******** *******@TK2MSFT NGP02.phx.gbl.. .
"Bart" <b@b.dwrote in message
news:et******** ******@TK2MSFTN GP05.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
9361
by: Jon S via DotNetMonster.com | last post by:
HI all, I'm returning a dataset to a gridview control. When the gridview asp.net control is populated from the returning dataset some of the cells remain empty. This is expected as some data in the dataset is empty. The cells that are empty, in the gridview control, I would like to have the value of 0 (zero) inserted. Is there a default...
11
14992
by: Jo | last post by:
Hi all, I have a gridview displaying a dataset and some buttons. When a certain cell of this datasetrow is empty, I want a button in that row to be visible, otherwise no button should be shown in that row. I'm trying to make this work all day, but it's not going to work. I tried this in the rowCreated event. I am able to find the right...
2
3582
by: Chris Davoli | last post by:
How do you enable a check box in the GridView. I selected Checkbox Field in the Columns of the GridView, and the check box shows up in the Grid view, but it is disabled. How do I enable it so I can check/uncheck it. Also, what event do I use to check it for a value? Any articles out there? -- Chris Davoli
3
1737
gchq
by: gchq | last post by:
Using both static data and data from some GridView cells I am attempting to calculate a result in a Template Cell - but to no avail! The value for TextBox1 is brought in on the page_load event and I'm attempting the balance of the calculation uisng the ItemDataBound event :- Protected Sub GridView1_ItemDataBound(ByVal sender As Object,...
1
27465
by: K B | last post by:
I would like to create a gridview as below: Project Name 1-1 1-2 1-3 1-4 1-5 1-6 Project 1 BLUE BLUE BLUE BLUE GREEN GREEN more projects I would like to fill the cell with a solid color based on the value of the cell (e.g., documents that are complete (blue) or not complete (green). In effect have a solid bar...
3
3301
by: Bill Gower | last post by:
I have an cell which contains a field member which is filled with String.Empty. When I retrieve the value in the cell with Cells.Text.ToString() and try to compare it to String.Empty, I can't because it contains "&nbsp". I really don't want to compare the value to that so how can I retrieve an empty cell so that it is String.Empty. Bill
1
4506
Frinavale
by: Frinavale | last post by:
I'm working on an ASP.NET application using VB.NET for server side code. I have a GridView listing a bunch of stuff. Above the GridView I have a checkbox named "ChkBx_SelectAll". If this checkbox is checked, all of the rows in the GridView are checked, if this checkbox is unchecked, all of the rows in the GridView are unchecked. This...
0
1263
by: S_K | last post by:
Hi, I have an editible GridView that I can read the contents of each cell of the edit row as follows: int iEditIndex = GridView2.EditIndex; string strName = GridView2.Rows.Cells.Text; This works fine with the HTML of the cell set up as follows (note the readonly="True"):
4
5846
by: foolmelon | last post by:
Before AJAX, we were able to focus a cell in a gridview during a fullpage postback. After putting the gridview inside an UpdatePanel, we cannot focus a cell in this gridview anymore. Does anybody know if it is possible to make such focus? Thanks! Bill
0
7409
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...
0
7766
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5981
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5341
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4958
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...
0
3463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1022
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
715
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...

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.