473,657 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrid bound to DataTable containing blanks returns  

anyone know why this is ?

Imports System.Data

Imports System.Diagnost ics

Public Class WebForm12

Inherits System.Web.UI.P age

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnos tics.DebuggerSt epThrough()> Private Sub InitializeCompo nent()

End Sub

Protected WithEvents dg1 As System.Web.UI.W ebControls.Data Grid

'NOTE: The following placeholder declaration is required by the Web Form
Designer.

'Do not delete or move it.

Private designerPlaceho lderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeCompo nent()

End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

Dim dcc As DataColumnColle ction

Dim dr As DataRow

Dim drc As DataRowCollecti on

Dim dt As DataTable

Try

If Not Page.IsPostBack Then

dt = New DataTable

dcc = dt.Columns

dcc.Add("Col1", GetType(String) )

dcc.Add("Col2", GetType(String) )

drc = dt.Rows

dr = dt.NewRow

dr(0) = "abcd"

'dr(1) = ""

drc.Add(dr)

dr = dt.NewRow

dr(0) = "efgh"

'dr(1) = ""

drc.Add(dr)

dg1.DataSource = dt.DefaultView

dg1.DataBind()

End If

Catch ex As Exception

Debug.WriteLine (ex.Source & " " & ex.Message)

Finally

End Try

End Sub

Public Sub dg1_ItemCommand (ByVal sender As Object, ByVal e As
DataGridCommand EventArgs)

Dim dgi As DataGridItem

Dim s As String

Dim s1 As String

Try

dg1.SelectedInd ex = e.Item.ItemInde x

dgi = dg1.SelectedIte m

s = dgi.Cells(1).Te xt

'Debug mode mouse-over reveals s = "&nbsp;"

s1 = Trim(Server.Htm lDecode(s))

Catch ex As Exception

Debug.WriteLine (ex.Source & " " & ex.Message)

Finally

End Try

End Sub

End Class
Nov 18 '05 #1
2 1984
John,

I suppose it could be that if you have a 2x2 table for example written as

<TABLE>
<TR>
<TD>
Cell 1:1
</TD>
<TD>
</TD>
</TR>
<TR>
<TD>
</TD>
<TD>
</TD>
</TR>
</TABLE>

you'll not see the individual emtpy cells in this table. But if you insert a
space (&nbsp;) into each cell, then you'll be able to see the borders around
each cell in the grid affect... To see my point, create a new HTML file
which contains one table where the empty cells really are empty, and where
the empty cells have a "&nbsp;" spacer.

The fact is that a datagrid gets rendered to the client as a table, so if
the empty cells didn't have these characters, the grid would look quite odd.

Thanks.

Dan.

"John A Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:e6******** ******@TK2MSFTN GP14.phx.gbl...
anyone know why this is ?

Imports System.Data

Imports System.Diagnost ics

Public Class WebForm12

Inherits System.Web.UI.P age

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()

End Sub

Protected WithEvents dg1 As System.Web.UI.W ebControls.Data Grid

'NOTE: The following placeholder declaration is required by the Web Form
Designer.

'Do not delete or move it.

Private designerPlaceho lderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeCompo nent()

End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

Dim dcc As DataColumnColle ction

Dim dr As DataRow

Dim drc As DataRowCollecti on

Dim dt As DataTable

Try

If Not Page.IsPostBack Then

dt = New DataTable

dcc = dt.Columns

dcc.Add("Col1", GetType(String) )

dcc.Add("Col2", GetType(String) )

drc = dt.Rows

dr = dt.NewRow

dr(0) = "abcd"

'dr(1) = ""

drc.Add(dr)

dr = dt.NewRow

dr(0) = "efgh"

'dr(1) = ""

drc.Add(dr)

dg1.DataSource = dt.DefaultView

dg1.DataBind()

End If

Catch ex As Exception

Debug.WriteLine (ex.Source & " " & ex.Message)

Finally

End Try

End Sub

Public Sub dg1_ItemCommand (ByVal sender As Object, ByVal e As
DataGridCommand EventArgs)

Dim dgi As DataGridItem

Dim s As String

Dim s1 As String

Try

dg1.SelectedInd ex = e.Item.ItemInde x

dgi = dg1.SelectedIte m

s = dgi.Cells(1).Te xt

'Debug mode mouse-over reveals s = "&nbsp;"

s1 = Trim(Server.Htm lDecode(s))

Catch ex As Exception

Debug.WriteLine (ex.Source & " " & ex.Message)

Finally

End Try

End Sub

End Class

Nov 18 '05 #2
Some browsers don't handle blank cells well.

Eliyahu

"John A Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:e6******** ******@TK2MSFTN GP14.phx.gbl...
anyone know why this is ?

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
6026
by: Tjerk Wolterink | last post by:
In XHTML the entity nbsp stands for   A normal space like " " is also displayed as an normal space, but multiple spaces like " " are interpreted as 1 space in the xhtml page. So there comes the &nbsp; in handy: with "&nbsp;&nbsp;" you have two spaces. So with the nbsp entity you can create multiple spaces (in the display). Now i have an xml file with &nbsp; entities, i put it in an xsl-file that know xhtml entities.
12
47677
by: Robert Mark Bram | last post by:
Hi All, I am using the following trim function: function trim (str) { return str.replace(/^\s*/g, '').replace(/\s*$/g, ''); } The problem is that this doesn't trim instances of the "&nbsp;" char - the non breaking space. Can this be represented in a grep statement at
2
3303
by: Bill Green | last post by:
I am trying to add an indent to a Dropdown control. I prefix the text for the ListItem with a couple &nbsp; but it doesn't render the tags to spaces , instead the dropdown list shows: MainItem &nbsp;&nbsp;SubItem &nbsp;&nbsp;SubItem Thanks, --
2
1979
by: Rob T | last post by:
I have a dropdown list that I would like to put in a bunch of &nbsp;'s into it (I'm setting the font to a monospace font so I can show a couple of columns nice and neat). In the old asp days, I had no problem doing this, but now if I try to do something like this... boxOption.Items.Add(New ListItem("myFirstCol&nbsp;&nbsp;&nbsp;myLastCol")) ....it converts each & to a &amp;
9
5816
by: Jouni Karppinen | last post by:
I create a HTMLTable in my C# code and then add rows and cells into that table. I'm trying to set top and bottom border for each cell by using stylesheet and it works as far as cell has some text in it. If cell has no content at all, the borders do not show up (..strange) So I tried to insert text inside each cell which has no other content inside. Cell content is set in code:
3
8916
by: yawnmoth | last post by:
<? echo 'a'.trim(html_entity_decode('&nbsp;a&nbsp;')).'a'; ?> Shouldn't PHP output aaa? Looking at the documentation for trim I see that it doesn't support chr(0xA0) (eg. html_entity_decode('&nbsp;')), but it seems to me like it ought to...
28
13185
by: entfred | last post by:
I have the following line of html: &nbsp;&nbsp1234&nbsp;&nbsp;&nbsp;&nbsp;&nbspabc&nbsp;&nbsp;&nbspyow In Internet Explorer 6.0, the columns look ok using the above html: 1234 abcd yow But, in firefox, for same html, getting this:
8
6492
by: wyo | last post by:
I'd like to display folder names without line breaks so I tried the following replace folders = f.replace(/ /g, '&nbsp;'); but the script stop without an error. Any idea? Is there a better way? O. Wyss
7
9743
by: Sebarry | last post by:
Hi, I'm having trouble creating a blank table row in Javascript using document.createElement( '&nbsp;' ). When I look at the generated source it has intrepreted it as <td>&amp;nbsp;</td>. What do I need to do? I've tried using single quotes, double quotes and backslash. Thanks, Sean
0
8413
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
8324
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
8842
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8513
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
7352
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5642
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
4173
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
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.