469,642 Members | 1,113 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,642 developers. It's quick & easy.

disapearing gridlines in gridview

Hello Everyone,

I have a gridview. I am using template columns inside the gridview.
When I display the gridview on the web page and if there is no value in a
particular cell, gridline disappaers around that cell.I want the grid lines
to appear all the time even if the cell is empty. Can anyone tell me what am
I doing wrong. Below is my gridview. I am showing only one template column. I
have around 14 template column in the gridview.
<asp:GridView ID="dgAgentActivity" runat="server"
AutoGenerateColumns="false" CellPadding="0" CellSpacing="1"
BackColor="AliceBlue" OnRowCreated="dgAgentActivity_RowCreated"
ShowFooter="true" >
<Columns>

<asp:templatefield headertext="SwitchTime" >

<itemtemplate>
<%#Eval("SwitchTime")%>
</itemtemplate>
<footertemplate>
<asp:label id="SwitchTime" runat="server"/>
</footertemplate>
</asp:templatefield>
<columns>

Thanks.

Apr 26 '07 #1
4 6468
That's how the browser renders a <tdthat has no content. Often, an nbsp;
is put in such a TD to get it to render the way you want it. So, depending
on how you get your data or how you want to do it, you may want to consider
replacing empty values with &nbsp;.

Notice what happens if you add this:
<style type="text/css">
table.Vinki td { height: 3em; border: 1px solid #000000; }
</style>

And give your GridView a CssClass="Vinki" property. Load this in IE and
then in Firefox. It's all in how each browser decides to deal with things,
and it's a pita!

Ray at work

"Vinki" <Vi***@discussions.microsoft.comwrote in message
news:AF**********************************@microsof t.com...
Hello Everyone,

I have a gridview. I am using template columns inside the gridview.
When I display the gridview on the web page and if there is no value in a
particular cell, gridline disappaers around that cell.I want the grid
lines
to appear all the time even if the cell is empty. Can anyone tell me what
am
I doing wrong. Below is my gridview. I am showing only one template
column. I
have around 14 template column in the gridview.
<asp:GridView ID="dgAgentActivity" runat="server"
AutoGenerateColumns="false" CellPadding="0" CellSpacing="1"
BackColor="AliceBlue" OnRowCreated="dgAgentActivity_RowCreated"
ShowFooter="true" >
<Columns>

<asp:templatefield headertext="SwitchTime" >

<itemtemplate>
<%#Eval("SwitchTime")%>
</itemtemplate>
<footertemplate>
<asp:label id="SwitchTime" runat="server"/>
</footertemplate>
</asp:templatefield>
<columns>

Thanks.
Apr 26 '07 #2
Hi Ray,

Thanks for replying. Do you know any way or if you have any example, I can
replace the empty cells with in gridview.

Thanks.

"Ray Costanzo" wrote:
That's how the browser renders a <tdthat has no content. Often, an nbsp;
is put in such a TD to get it to render the way you want it. So, depending
on how you get your data or how you want to do it, you may want to consider
replacing empty values with .

Notice what happens if you add this:
<style type="text/css">
table.Vinki td { height: 3em; border: 1px solid #000000; }
</style>

And give your GridView a CssClass="Vinki" property. Load this in IE and
then in Firefox. It's all in how each browser decides to deal with things,
and it's a pita!

Ray at work

"Vinki" <Vi***@discussions.microsoft.comwrote in message
news:AF**********************************@microsof t.com...
Hello Everyone,

I have a gridview. I am using template columns inside the gridview.
When I display the gridview on the web page and if there is no value in a
particular cell, gridline disappaers around that cell.I want the grid
lines
to appear all the time even if the cell is empty. Can anyone tell me what
am
I doing wrong. Below is my gridview. I am showing only one template
column. I
have around 14 template column in the gridview.
<asp:GridView ID="dgAgentActivity" runat="server"
AutoGenerateColumns="false" CellPadding="0" CellSpacing="1"
BackColor="AliceBlue" OnRowCreated="dgAgentActivity_RowCreated"
ShowFooter="true" >
<Columns>

<asp:templatefield headertext="SwitchTime" >

<itemtemplate>
<%#Eval("SwitchTime")%>
</itemtemplate>
<footertemplate>
<asp:label id="SwitchTime" runat="server"/>
</footertemplate>
</asp:templatefield>
<columns>

Thanks.
Apr 26 '07 #3
Hi Ray,

I tried doing this

for (int i = 0; i <= 17; i++)
{
if
(((DataBoundLiteralControl)e.Row.Cells[2].Controls[0]).Text.Trim() ==
string.Empty)

((DataBoundLiteralControl)e.Row.Cells[2].Controls[0]).Text = "&nbsp";

}

but this didn't work. I have 18 template columns so I want to do it in a
loop. Is there any other way I can do it.

"Ray Costanzo" wrote:
That's how the browser renders a <tdthat has no content. Often, an nbsp;
is put in such a TD to get it to render the way you want it. So, depending
on how you get your data or how you want to do it, you may want to consider
replacing empty values with .

Notice what happens if you add this:
<style type="text/css">
table.Vinki td { height: 3em; border: 1px solid #000000; }
</style>

And give your GridView a CssClass="Vinki" property. Load this in IE and
then in Firefox. It's all in how each browser decides to deal with things,
and it's a pita!

Ray at work

"Vinki" <Vi***@discussions.microsoft.comwrote in message
news:AF**********************************@microsof t.com...
Hello Everyone,

I have a gridview. I am using template columns inside the gridview.
When I display the gridview on the web page and if there is no value in a
particular cell, gridline disappaers around that cell.I want the grid
lines
to appear all the time even if the cell is empty. Can anyone tell me what
am
I doing wrong. Below is my gridview. I am showing only one template
column. I
have around 14 template column in the gridview.
<asp:GridView ID="dgAgentActivity" runat="server"
AutoGenerateColumns="false" CellPadding="0" CellSpacing="1"
BackColor="AliceBlue" OnRowCreated="dgAgentActivity_RowCreated"
ShowFooter="true" >
<Columns>

<asp:templatefield headertext="SwitchTime" >

<itemtemplate>
<%#Eval("SwitchTime")%>
</itemtemplate>
<footertemplate>
<asp:label id="SwitchTime" runat="server"/>
</footertemplate>
</asp:templatefield>
<columns>

Thanks.
Apr 26 '07 #4
Yeah, I'd say your best bet is to go for a solution that does not involve
modifying your data.

There is a CSS attribute for the table element called empty-cells, but as is
typical, IE doesn't support it. But, if you set border-collapse to collapse
at the table level, IE will show the border on the empty cells. Hopefully
this will fit with the look you're going for.

<style type="text/css">
table.test { border-collapse: collapse; }
table.test td { border: 1px solid #000000; empty-cells: show; width: 33%}
</style>
<table class="test">
<tr>
<td>content</td>
<td></td>
<td>content</td>
</tr>
</table>

Ray at work
"Vinki" <Vi***@discussions.microsoft.comwrote in message
news:8E**********************************@microsof t.com...
Hi Ray,

I tried doing this

for (int i = 0; i <= 17; i++)
{
if
(((DataBoundLiteralControl)e.Row.Cells[2].Controls[0]).Text.Trim() ==
string.Empty)

((DataBoundLiteralControl)e.Row.Cells[2].Controls[0]).Text = "&nbsp";

}

but this didn't work. I have 18 template columns so I want to do it in a
loop. Is there any other way I can do it.

"Ray Costanzo" wrote:
>That's how the browser renders a <tdthat has no content. Often, an
nbsp;
is put in such a TD to get it to render the way you want it. So,
depending
on how you get your data or how you want to do it, you may want to
consider
replacing empty values with .

Notice what happens if you add this:
<style type="text/css">
table.Vinki td { height: 3em; border: 1px solid #000000; }
</style>

And give your GridView a CssClass="Vinki" property. Load this in IE and
then in Firefox. It's all in how each browser decides to deal with
things,
and it's a pita!

Ray at work

"Vinki" <Vi***@discussions.microsoft.comwrote in message
news:AF**********************************@microso ft.com...
Hello Everyone,

I have a gridview. I am using template columns inside the gridview.
When I display the gridview on the web page and if there is no value in
a
particular cell, gridline disappaers around that cell.I want the grid
lines
to appear all the time even if the cell is empty. Can anyone tell me
what
am
I doing wrong. Below is my gridview. I am showing only one template
column. I
have around 14 template column in the gridview.
<asp:GridView ID="dgAgentActivity" runat="server"
AutoGenerateColumns="false" CellPadding="0" CellSpacing="1"
BackColor="AliceBlue" OnRowCreated="dgAgentActivity_RowCreated"
ShowFooter="true" >
<Columns>

<asp:templatefield headertext="SwitchTime" >

<itemtemplate>
<%#Eval("SwitchTime")%>
</itemtemplate>
<footertemplate>
<asp:label id="SwitchTime" runat="server"/>
</footertemplate>
</asp:templatefield>
<columns>

Thanks.
Apr 27 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Matt | last post: by
2 posts views Thread by Mike P | last post: by
7 posts views Thread by =?Utf-8?B?U0FM?= | last post: by
reply views Thread by =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.