disapearing gridlines in gridview

Discussion in 'ASP .Net' started by =?Utf-8?B?Vmlua2k=?=, Apr 26, 2007.

  1. 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.
     
    =?Utf-8?B?Vmlua2k=?=, Apr 26, 2007
    #1
    1. Advertising

  2. =?Utf-8?B?Vmlua2k=?=

    Ray Costanzo Guest

    That's how the browser renders a <td> that 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" <> wrote in message
    news:...
    > 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.
    >
     
    Ray Costanzo, Apr 26, 2007
    #2
    1. Advertising

  3. 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 <td> that 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" <> wrote in message
    > news:...
    > > 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.
    > >

    >
     
    =?Utf-8?B?Vmlua2k=?=, Apr 26, 2007
    #3
  4. 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 <td> that 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" <> wrote in message
    > news:...
    > > 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.
    > >

    >
     
    =?Utf-8?B?Vmlua2k=?=, Apr 26, 2007
    #4
  5. =?Utf-8?B?Vmlua2k=?=

    Ray Costanzo Guest

    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" <> wrote in message
    news:...
    > 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 <td> that 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" <> wrote in message
    >> news:...
    >> > 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.
    >> >

    >>
     
    Ray Costanzo, Apr 27, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ThunderMusic

    Disapearing cursor on some Readonly textbox

    ThunderMusic, Jan 23, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    915
    ThunderMusic
    Jan 23, 2006
  2. Mike P

    GridView Gridlines

    Mike P, Apr 26, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    923
    Mike P
    Apr 26, 2006
  3. tshad

    Gridview Gridlines color

    tshad, Jan 19, 2010, in forum: ASP .Net
    Replies:
    2
    Views:
    3,329
    tshad
    Jan 20, 2010
  4. Magnus Blomberg

    GridView -> Excel = no gridlines

    Magnus Blomberg, Oct 21, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    209
    Magnus Blomberg
    Oct 21, 2005
  5. Vinki

    disappearing gridlines in gridview

    Vinki, Apr 26, 2007, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    261
    KyleK
    May 17, 2007
Loading...

Share This Page