adding table inside itemtemplate

Discussion in 'ASP .Net' started by Edge, Jan 9, 2006.

  1. Edge

    Edge Guest

    hi all,

    I added a html table with 2 rows inside the itemtemplate of my gridview.
    It works ok, but the table border never touches the border of my gridview
    cell.

    How should I do if I want the internal table and my grid cell share the same
    border, so noone realizes that there is a table inside my cell?

    TIA
    -E
     
    Edge, Jan 9, 2006
    #1
    1. Advertising

  2. Edge,

    By default, your datagrid will generate cells with padding - therefore your
    inside table's border appears separately. Create a class for td that has no
    padding and ensure that your ItemTemplate CssClass is set to it. Something
    like:

    <style>td.noPad{padding:0px}</style>
    <asp:DataGrid ...>
    <ItemTemplate CssClass="noPad" ..
    </asp:DataGrid>

    Unfortunately I do not have an ability to test it, but it is very likely to
    fix your problem.

    "Edge" wrote:

    > hi all,
    >
    > I added a html table with 2 rows inside the itemtemplate of my gridview.
    > It works ok, but the table border never touches the border of my gridview
    > cell.
    >
    > How should I do if I want the internal table and my grid cell share the same
    > border, so noone realizes that there is a table inside my cell?
    >
    > TIA
    > -E
    >
    >
    >
     
    =?Utf-8?B?U2VyZ2V5IFBvYmVyZXpvdnNraXk=?=, Jan 9, 2006
    #2
    1. Advertising

  3. Edge

    Edge Guest

    hi Sergey,
    I just tried this but it did not work

    -E


    "Sergey Poberezovskiy" <> wrote
    in message news:...
    > Edge,
    >
    > By default, your datagrid will generate cells with padding - therefore
    > your
    > inside table's border appears separately. Create a class for td that has
    > no
    > padding and ensure that your ItemTemplate CssClass is set to it. Something
    > like:
    >
    > <style>td.noPad{padding:0px}</style>
    > <asp:DataGrid ...>
    > <ItemTemplate CssClass="noPad" ..
    > </asp:DataGrid>
    >
    > Unfortunately I do not have an ability to test it, but it is very likely
    > to
    > fix your problem.
    >
    > "Edge" wrote:
    >
    >> hi all,
    >>
    >> I added a html table with 2 rows inside the itemtemplate of my gridview.
    >> It works ok, but the table border never touches the border of my gridview
    >> cell.
    >>
    >> How should I do if I want the internal table and my grid cell share the
    >> same
    >> border, so noone realizes that there is a table inside my cell?
    >>
    >> TIA
    >> -E
    >>
    >>
    >>
     
    Edge, Jan 9, 2006
    #3
  4. Could you post some code, say create a sample page that demonstrates your
    problem - I will look into it - it seems to me as css task rather than
    anything else - could be some other styles just cascade through ...


    "Edge" wrote:

    > hi Sergey,
    > I just tried this but it did not work
    >
    > -E
    >
    >
    > "Sergey Poberezovskiy" <> wrote
    > in message news:...
    > > Edge,
    > >
    > > By default, your datagrid will generate cells with padding - therefore
    > > your
    > > inside table's border appears separately. Create a class for td that has
    > > no
    > > padding and ensure that your ItemTemplate CssClass is set to it. Something
    > > like:
    > >
    > > <style>td.noPad{padding:0px}</style>
    > > <asp:DataGrid ...>
    > > <ItemTemplate CssClass="noPad" ..
    > > </asp:DataGrid>
    > >
    > > Unfortunately I do not have an ability to test it, but it is very likely
    > > to
    > > fix your problem.
    > >
    > > "Edge" wrote:
    > >
    > >> hi all,
    > >>
    > >> I added a html table with 2 rows inside the itemtemplate of my gridview.
    > >> It works ok, but the table border never touches the border of my gridview
    > >> cell.
    > >>
    > >> How should I do if I want the internal table and my grid cell share the
    > >> same
    > >> border, so noone realizes that there is a table inside my cell?
    > >>
    > >> TIA
    > >> -E
    > >>
    > >>
    > >>

    >
    >
    >
     
    =?Utf-8?B?U2VyZ2V5IFBvYmVyZXpvdnNraXk=?=, Jan 9, 2006
    #4
  5. Edge

    Edge Guest

    hi,
    here it is the gridview and its css:

    <asp:GridView ID="dgResults" runat="server" AutoGenerateColumns="False"
    CssClass="GridTextCenter"
    HeaderStyle-CssClass="GridHeaderCenter" Width="100%"
    RowStyle-VerticalAlign="Top"
    Visible="false" OnRowDataBound="dgResults_RowDataBound">
    <Columns>
    <asp:TemplateField HeaderStyle-BorderColor="black"
    ItemStyle-BorderColor="black">
    <HeaderTemplate>
    No.
    </HeaderTemplate>
    <ItemTemplate>
    <table><tr><td colspan=2><%# Eval("Row") %></td>
    <tr><td>value a</td><td>value b</td></tr></table>
    </ItemTemplate>
    </asp:TemplateField>
    ....

    ..GridTextCenter
    {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: normal;
    color: #000000;
    text-decoration: none;
    line-height: 1.5;
    text-align:center;
    background-color:White;
    border-color:Black;
    }

    ..GridHeaderCenter
    {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: bold;
    color: black;
    line-height: 2;
    text-decoration: none;
    background-color:#87cefa ;
    text-align:center;

    }



    "Sergey Poberezovskiy" <> wrote
    in message news:...
    > Could you post some code, say create a sample page that demonstrates your
    > problem - I will look into it - it seems to me as css task rather than
    > anything else - could be some other styles just cascade through ...
    >
    >
    > "Edge" wrote:
    >
    >> hi Sergey,
    >> I just tried this but it did not work
    >>
    >> -E
    >>
    >>
    >> "Sergey Poberezovskiy" <>
    >> wrote
    >> in message news:...
    >> > Edge,
    >> >
    >> > By default, your datagrid will generate cells with padding - therefore
    >> > your
    >> > inside table's border appears separately. Create a class for td that
    >> > has
    >> > no
    >> > padding and ensure that your ItemTemplate CssClass is set to it.
    >> > Something
    >> > like:
    >> >
    >> > <style>td.noPad{padding:0px}</style>
    >> > <asp:DataGrid ...>
    >> > <ItemTemplate CssClass="noPad" ..
    >> > </asp:DataGrid>
    >> >
    >> > Unfortunately I do not have an ability to test it, but it is very
    >> > likely
    >> > to
    >> > fix your problem.
    >> >
    >> > "Edge" wrote:
    >> >
    >> >> hi all,
    >> >>
    >> >> I added a html table with 2 rows inside the itemtemplate of my
    >> >> gridview.
    >> >> It works ok, but the table border never touches the border of my
    >> >> gridview
    >> >> cell.
    >> >>
    >> >> How should I do if I want the internal table and my grid cell share
    >> >> the
    >> >> same
    >> >> border, so noone realizes that there is a table inside my cell?
    >> >>
    >> >> TIA
    >> >> -E
    >> >>
    >> >>
    >> >>

    >>
    >>
    >>
     
    Edge, Jan 11, 2006
    #5
  6. Try the following:

    <style>.inTable{height:100%;width:100%;border:black 0px solid;}
    td.noPad{padding:0px}</style>
    <asp:DataGrid ...>
    ....
    <asp:TemplateField HeaderStyle-BorderColor="black"
    ItemStyle-CssClass="noPad">
    <HeaderTemplate>
    No.
    </HeaderTemplate>
    <ItemTemplate>
    <table class="inTable"><tr><td colspan=2><%# Eval("Row") %></td>
    <tr><td>value a</td><td>value b</td></tr></table>
    </ItemTemplate>
    </asp:TemplateField>
    </asp:DataGrid>

    I think that at least two things are happening: your ItemStyle uses 1px as
    default padding, and because internal table is not stretched - it is
    positioned at the center according to your stylesheet.


    "Edge" wrote:

    > hi,
    > here it is the gridview and its css:
    >
    > <asp:GridView ID="dgResults" runat="server" AutoGenerateColumns="False"
    > CssClass="GridTextCenter"
    > HeaderStyle-CssClass="GridHeaderCenter" Width="100%"
    > RowStyle-VerticalAlign="Top"
    > Visible="false" OnRowDataBound="dgResults_RowDataBound">
    > <Columns>
    > <asp:TemplateField HeaderStyle-BorderColor="black"
    > ItemStyle-BorderColor="black">
    > <HeaderTemplate>
    > No.
    > </HeaderTemplate>
    > <ItemTemplate>
    > <table><tr><td colspan=2><%# Eval("Row") %></td>
    > <tr><td>value a</td><td>value b</td></tr></table>
    > </ItemTemplate>
    > </asp:TemplateField>
    > ....
    >
    > ..GridTextCenter
    > {
    > font-family: Arial, Helvetica, sans-serif;
    > font-size: 12px;
    > font-weight: normal;
    > color: #000000;
    > text-decoration: none;
    > line-height: 1.5;
    > text-align:center;
    > background-color:White;
    > border-color:Black;
    > }
    >
    > ..GridHeaderCenter
    > {
    > font-family: Arial, Helvetica, sans-serif;
    > font-size: 12px;
    > font-weight: bold;
    > color: black;
    > line-height: 2;
    > text-decoration: none;
    > background-color:#87cefa ;
    > text-align:center;
    >
    > }
    >
    >
    >
    > "Sergey Poberezovskiy" <> wrote
    > in message news:...
    > > Could you post some code, say create a sample page that demonstrates your
    > > problem - I will look into it - it seems to me as css task rather than
    > > anything else - could be some other styles just cascade through ...
    > >
    > >
    > > "Edge" wrote:
    > >
    > >> hi Sergey,
    > >> I just tried this but it did not work
    > >>
    > >> -E
    > >>
    > >>
    > >> "Sergey Poberezovskiy" <>
    > >> wrote
    > >> in message news:...
    > >> > Edge,
    > >> >
    > >> > By default, your datagrid will generate cells with padding - therefore
    > >> > your
    > >> > inside table's border appears separately. Create a class for td that
    > >> > has
    > >> > no
    > >> > padding and ensure that your ItemTemplate CssClass is set to it.
    > >> > Something
    > >> > like:
    > >> >
    > >> > <style>td.noPad{padding:0px}</style>
    > >> > <asp:DataGrid ...>
    > >> > <ItemTemplate CssClass="noPad" ..
    > >> > </asp:DataGrid>
    > >> >
    > >> > Unfortunately I do not have an ability to test it, but it is very
    > >> > likely
    > >> > to
    > >> > fix your problem.
    > >> >
    > >> > "Edge" wrote:
    > >> >
    > >> >> hi all,
    > >> >>
    > >> >> I added a html table with 2 rows inside the itemtemplate of my
    > >> >> gridview.
    > >> >> It works ok, but the table border never touches the border of my
    > >> >> gridview
    > >> >> cell.
    > >> >>
    > >> >> How should I do if I want the internal table and my grid cell share
    > >> >> the
    > >> >> same
    > >> >> border, so noone realizes that there is a table inside my cell?
    > >> >>
    > >> >> TIA
    > >> >> -E
    > >> >>
    > >> >>
    > >> >>
    > >>
    > >>
    > >>

    >
    >
    >
     
    =?Utf-8?B?U2VyZ2V5IFBvYmVyZXpvdnNraXk=?=, Jan 12, 2006
    #6
  7. Edge

    Edge Guest

    yep...worked very well :)
    Thanks a lot
    Edge


    "Sergey Poberezovskiy" <> wrote
    in message news:...
    > Try the following:
    >
    > <style>.inTable{height:100%;width:100%;border:black 0px solid;}
    > td.noPad{padding:0px}</style>
    > <asp:DataGrid ...>
    > ...
    > <asp:TemplateField HeaderStyle-BorderColor="black"
    > ItemStyle-CssClass="noPad">
    > <HeaderTemplate>
    > No.
    > </HeaderTemplate>
    > <ItemTemplate>
    > <table class="inTable"><tr><td colspan=2><%# Eval("Row") %></td>
    > <tr><td>value a</td><td>value b</td></tr></table>
    > </ItemTemplate>
    > </asp:TemplateField>
    > </asp:DataGrid>
    >
    > I think that at least two things are happening: your ItemStyle uses 1px as
    > default padding, and because internal table is not stretched - it is
    > positioned at the center according to your stylesheet.
    >
    >
    > "Edge" wrote:
    >
    >> hi,
    >> here it is the gridview and its css:
    >>
    >> <asp:GridView ID="dgResults" runat="server" AutoGenerateColumns="False"
    >> CssClass="GridTextCenter"
    >> HeaderStyle-CssClass="GridHeaderCenter" Width="100%"
    >> RowStyle-VerticalAlign="Top"
    >> Visible="false" OnRowDataBound="dgResults_RowDataBound">
    >> <Columns>
    >> <asp:TemplateField HeaderStyle-BorderColor="black"
    >> ItemStyle-BorderColor="black">
    >> <HeaderTemplate>
    >> No.
    >> </HeaderTemplate>
    >> <ItemTemplate>
    >> <table><tr><td colspan=2><%# Eval("Row") %></td>
    >> <tr><td>value a</td><td>value b</td></tr></table>
    >> </ItemTemplate>
    >> </asp:TemplateField>
    >> ....
    >>
    >> ..GridTextCenter
    >> {
    >> font-family: Arial, Helvetica, sans-serif;
    >> font-size: 12px;
    >> font-weight: normal;
    >> color: #000000;
    >> text-decoration: none;
    >> line-height: 1.5;
    >> text-align:center;
    >> background-color:White;
    >> border-color:Black;
    >> }
    >>
    >> ..GridHeaderCenter
    >> {
    >> font-family: Arial, Helvetica, sans-serif;
    >> font-size: 12px;
    >> font-weight: bold;
    >> color: black;
    >> line-height: 2;
    >> text-decoration: none;
    >> background-color:#87cefa ;
    >> text-align:center;
    >>
    >> }
    >>
    >>
    >>
    >> "Sergey Poberezovskiy" <>
    >> wrote
    >> in message news:...
    >> > Could you post some code, say create a sample page that demonstrates
    >> > your
    >> > problem - I will look into it - it seems to me as css task rather than
    >> > anything else - could be some other styles just cascade through ...
    >> >
    >> >
    >> > "Edge" wrote:
    >> >
    >> >> hi Sergey,
    >> >> I just tried this but it did not work
    >> >>
    >> >> -E
    >> >>
    >> >>
    >> >> "Sergey Poberezovskiy" <>
    >> >> wrote
    >> >> in message news:...
    >> >> > Edge,
    >> >> >
    >> >> > By default, your datagrid will generate cells with padding -
    >> >> > therefore
    >> >> > your
    >> >> > inside table's border appears separately. Create a class for td that
    >> >> > has
    >> >> > no
    >> >> > padding and ensure that your ItemTemplate CssClass is set to it.
    >> >> > Something
    >> >> > like:
    >> >> >
    >> >> > <style>td.noPad{padding:0px}</style>
    >> >> > <asp:DataGrid ...>
    >> >> > <ItemTemplate CssClass="noPad" ..
    >> >> > </asp:DataGrid>
    >> >> >
    >> >> > Unfortunately I do not have an ability to test it, but it is very
    >> >> > likely
    >> >> > to
    >> >> > fix your problem.
    >> >> >
    >> >> > "Edge" wrote:
    >> >> >
    >> >> >> hi all,
    >> >> >>
    >> >> >> I added a html table with 2 rows inside the itemtemplate of my
    >> >> >> gridview.
    >> >> >> It works ok, but the table border never touches the border of my
    >> >> >> gridview
    >> >> >> cell.
    >> >> >>
    >> >> >> How should I do if I want the internal table and my grid cell share
    >> >> >> the
    >> >> >> same
    >> >> >> border, so noone realizes that there is a table inside my cell?
    >> >> >>
    >> >> >> TIA
    >> >> >> -E
    >> >> >>
    >> >> >>
    >> >> >>
    >> >>
    >> >>
    >> >>

    >>
    >>
    >>
     
    Edge, Jan 12, 2006
    #7
    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. Bennett Haselton
    Replies:
    1
    Views:
    5,344
    Joe Fallon
    Sep 24, 2004
  2. Charlie@CBFC
    Replies:
    0
    Views:
    382
    Charlie@CBFC
    May 17, 2006
  3. Charlie@CBFC
    Replies:
    2
    Views:
    538
    Charlie@CBFC
    May 18, 2006
  4. Jim in Arizona

    Finding a control inside an <itemtemplate>

    Jim in Arizona, Jan 4, 2007, in forum: ASP .Net
    Replies:
    5
    Views:
    388
    Eliyahu Goldin
    Jan 4, 2007
  5. Oleg
    Replies:
    1
    Views:
    7,345
    Cowboy \(Gregory A. Beamer\)
    Mar 7, 2008
Loading...

Share This Page