GridView in a table

Discussion in 'ASP .Net' started by mattd1, Mar 25, 2008.

  1. mattd1

    mattd1 Guest

    I'm using VS2008, and I need to put a gridview into a table cell (an asp
    table). I made the gridview and set it all up outside the table, then I edit
    the HTML and move the gridview into the table cell it should go into, but
    then it doesn't show no matter what I do. It's like it's invisible. If I
    drag the HTML that describes the gridview out of the table cell and on its
    own, the gridview shows fine.

    Is there some problem with putting a gridview in a table cell (unlikely) or
    can someone tell me what the trick is?

    Matt
    mattd1, Mar 25, 2008
    #1
    1. Advertising

  2. mattd1

    mattd1 Guest

    Hi David -

    Here's the HTML. I haven't even started with the codebehind yet.

    <asp:Table ID="tblSearchAndLeaseExpirations" runat="server"
    Height="167px"
    Width="100%" BorderColor="Black" BorderStyle="Solid"
    BorderWidth="1px"
    CellPadding="10" GridLines="Both">
    <asp:TableRow runat="server" Width="100%">
    <asp:TableCell runat="server" Width="50%" ID="tclSearch">
    <asp:Table ID="tblSearchBox" runat="server"
    BackColor="Cornsilk" Width="100%"
    BorderColor="Black" BorderStyle="Solid"
    BorderWidth="1px">

    <asp:TableRow ID="TableRow1" runat="server">
    <asp:TableCell ID="TableCell1" runat="server"
    BackColor="CornflowerBlue" Font-Bold="True"
    Font-Names="Arial" ForeColor="White">Search for
    servers</asp:TableCell>
    </asp:TableRow>

    <asp:TableRow ID="TableRow2" runat="server">
    <asp:TableCell ID="TableCell2" runat="server"
    Font-Names="Tahoma" Font-Size="Smaller">Type a
    server name or select one from the list. Wildcards
    (* and ?) are supported</asp:TableCell>
    </asp:TableRow>

    <asp:TableRow ID="TableRow3" runat="server">
    <asp:TableCell ID="tclErrorMessage" runat="server"
    Font-Names="Tahoma" Font-Size="Smaller"
    ForeColor="Red">That is not a valid server.
    Please enter another name.</asp:TableCell>
    </asp:TableRow>

    <asp:TableRow ID="TableRow4" runat="server">
    <asp:TableCell ID="TableCell4" runat="server">
    <asp:TextBox ID="txtServerName" runat="server"
    Width="75%">*</asp:TextBox>
    </asp:TableCell>
    </asp:TableRow>
    </asp:Table>

    <asp:Table ID="tblSearchBoxControls" runat="server"
    Width="100%" BorderColor="Black"
    BorderStyle="Solid" BorderWidth="1px">
    <asp:TableRow ID="TableRow5" runat="server">
    <asp:TableCell ID="TableCell5" runat="server"
    BackColor="Cornsilk" Width="50%">
    <asp:CheckBox ID="chkSearchAll" runat="server"
    BackColor="Cornsilk"
    Font-Names="Tahoma" Font-Size="Smaller"
    Text="Search All"/>
    </asp:TableCell>

    <asp:TableCell ID="TableCell6" runat="server"
    BackColor="Cornsilk" HorizontalAlign="Right">
    <asp:Button ID="cmdGetServer" runat="server"
    Font-Names="Tahoma"
    Font-Size="Smaller" Text="Get Server"
    Width="76" Height="21" />
    </asp:TableCell>
    </asp:TableRow>
    </asp:Table>

    </asp:TableCell>

    <asp:TableCell runat="server" Width="50%"
    ID="tclLeaseExpiration">
    <asp:Table ID="tblLeaseExpirations" runat="server"
    Height="100%" Width="100%">
    <asp:TableRow runat="server" Height="20px">
    <asp:TableCell runat="server"
    BackColor="CornflowerBlue" Font-Names="Arial"
    Font-Size="Larger" ForeColor="White">Lease
    Expirations Next 90 Days
    </asp:TableCell>
    </asp:TableRow>

    <asp:TableRow runat="server">
    <asp:TableCell runat="server"
    Font-Names="Arial">No servers are going end of lease in the next 90 days

    <asp:GridView ID="dgData" runat="server"
    AllowPaging="True"
    AutoGenerateColumns="False"
    EnableSortingAndPagingCallbacks="True"
    Font-Names="Arial"
    Font-Size="Medium" PageSize="4">
    <PagerSettings Position="Top" />
    <Columns>
    <asp:ButtonField
    DataTextField="server_name" HeaderText="Server Name"
    ShowHeader="True"
    Text="Button" />
    <asp:BoundField
    DataField="exp_lease" DataFormatString="{0:MM/dd/yyyy}"
    HeaderText="Expiration" />
    <asp:BoundField
    DataField="status" HeaderText="Status" />
    <asp:BoundField
    DataField="Server_Id" HeaderText="Server Id" Visible="False" />
    </Columns>
    <PagerStyle
    BackColor="CornflowerBlue" Font-Bold="True" Font-Names="Tahoma"
    Font-Size="Small"
    ForeColor="White" />
    <HeaderStyle
    BackColor="CornflowerBlue" Font-Names="Arial" Font-Size="Medium"
    ForeColor="White" />
    <AlternatingRowStyle
    BackColor="Cornsilk" Font-Names="Arial"
    Font-Size="Medium" />
    </asp:GridView>

    </asp:TableCell>
    </asp:TableRow>
    </asp:Table>

    </asp:TableCell>
    </asp:TableRow>
    </asp:Table>

    Thanks for taking a look

    Matt

    "David R. Longnecker" <> wrote in message
    news:...
    Matt-

    Could you post an example of your code? As you mentioned--it should work.
    I tried reproducing the code and didn't have any trouble:

    aspx page:

    <asp:Table ID="tbl" runat="server" GridLines="Both">
    <asp:TableRow>
    <asp:TableCell Text="Hello, world!" /><asp:TableCell Text="Cell 2"
    />
    </asp:TableRow>
    <asp:TableRow>
    <asp:TableCell ColumnSpan="2">
    <p>GridView!</p>
    <asp:GridView ID="gv" runat="server" />
    </asp:TableCell>
    </asp:TableRow>
    </asp:Table>

    code-behind:

    protected void Page_Load(object sender, EventArgs e)
    {
    gv.DataSource = new NorthwindDataContext().Products.ToList();
    gv.DataBind();
    }

    See attached image for the results.

    HTH.

    -dl

    --
    David R. Longnecker
    http://blog.tiredstudent.com

    > I'm using VS2008, and I need to put a gridview into a table cell (an
    > asp table). I made the gridview and set it all up outside the table,
    > then I edit the HTML and move the gridview into the table cell it
    > should go into, but then it doesn't show no matter what I do. It's
    > like it's invisible. If I drag the HTML that describes the gridview
    > out of the table cell and on its own, the gridview shows fine.
    >
    > Is there some problem with putting a gridview in a table cell
    > (unlikely) or can someone tell me what the trick is?
    >
    > Matt
    >
    mattd1, Mar 26, 2008
    #2
    1. Advertising

  3. mattd1

    mattd1 Guest

    So, I see the problem. I didn't realize that .net hid the grid if there was
    no data. I didn't have that problem in 2005 (I'm translating the project to
    2008) because I used absolute positioning instead of tables, and as I recall
    the datagrid in 2005 showed regardless..

    You asked a couple times about the datasource, so you were correctly focused
    on the problem. Thanks a million for your help. I am moving from WinForms to
    web based for this app and I don't know all these webby quirks.

    Thanks again David. You were very helpful.

    Matt

    "David R. Longnecker" <> wrote in message
    news:...
    Matt-

    I copied the HTML you have below into a new aspx page, loaded up Northwind
    and picked out some similar data fields to yours, and it worked like a
    champ.

    I've attached an image of the results and a text file with the code I used
    to generate it (I had to change a few of the Ids when they copied over as
    the copy process plugged in Ids for your TableCells that didn't have them
    and duplicates cropped up).

    Code behind:

    protected void Page_Load(object sender, EventArgs e)
    {
    dgData.DataSource =
    new NorthwindDataContext()
    .Products
    .Select(x => new { x.ProductID, x.ProductName,
    x.Discontinued });
    dgData.DataBind();
    }

    How are you loading data into your grid view? Code-behind? DataSource
    control?

    -dl

    --
    David R. Longnecker
    http://blog.tiredstudent.com

    > Hi David -
    >
    > Here's the HTML. I haven't even started with the codebehind yet.
    >
    > <asp:Table ID="tblSearchAndLeaseExpirations" runat="server"
    > Height="167px"
    > Width="100%" BorderColor="Black" BorderStyle="Solid"
    > BorderWidth="1px"
    > CellPadding="10" GridLines="Both">
    > <asp:TableRow runat="server" Width="100%">
    > <asp:TableCell runat="server" Width="50%" ID="tclSearch">
    > <asp:Table ID="tblSearchBox" runat="server"
    > BackColor="Cornsilk" Width="100%"
    > BorderColor="Black" BorderStyle="Solid"
    > BorderWidth="1px">
    > <asp:TableRow ID="TableRow1" runat="server">
    > <asp:TableCell ID="TableCell1" runat="server"
    > BackColor="CornflowerBlue" Font-Bold="True"
    > Font-Names="Arial"
    > ForeColor="White">Search for
    > servers</asp:TableCell>
    > </asp:TableRow>
    > <asp:TableRow ID="TableRow2" runat="server">
    > <asp:TableCell ID="TableCell2" runat="server"
    > Font-Names="Tahoma" Font-Size="Smaller">Type a
    > server name or select one from the list.
    > Wildcards
    > (* and ?) are supported</asp:TableCell>
    > </asp:TableRow>
    > <asp:TableRow ID="TableRow3" runat="server">
    > <asp:TableCell ID="tclErrorMessage"
    > runat="server"
    > Font-Names="Tahoma" Font-Size="Smaller"
    > ForeColor="Red">That is not a valid
    > server.
    > Please enter another name.</asp:TableCell>
    > </asp:TableRow>
    > <asp:TableRow ID="TableRow4" runat="server">
    > <asp:TableCell ID="TableCell4" runat="server">
    > <asp:TextBox ID="txtServerName"
    > runat="server"
    > Width="75%">*</asp:TextBox>
    > </asp:TableCell>
    > </asp:TableRow>
    > </asp:Table>
    > <asp:Table ID="tblSearchBoxControls" runat="server"
    > Width="100%" BorderColor="Black"
    > BorderStyle="Solid" BorderWidth="1px">
    > <asp:TableRow ID="TableRow5" runat="server">
    > <asp:TableCell ID="TableCell5" runat="server"
    > BackColor="Cornsilk" Width="50%">
    > <asp:CheckBox ID="chkSearchAll"
    > runat="server"
    > BackColor="Cornsilk"
    > Font-Names="Tahoma"
    > Font-Size="Smaller"
    > Text="Search All"/>
    > </asp:TableCell>
    > <asp:TableCell ID="TableCell6" runat="server"
    > BackColor="Cornsilk" HorizontalAlign="Right">
    > <asp:Button ID="cmdGetServer"
    > runat="server"
    > Font-Names="Tahoma"
    > Font-Size="Smaller" Text="Get Server"
    > Width="76" Height="21" />
    > </asp:TableCell>
    > </asp:TableRow>
    > </asp:Table>
    > </asp:TableCell>
    >
    > <asp:TableCell runat="server" Width="50%"
    > ID="tclLeaseExpiration">
    > <asp:Table ID="tblLeaseExpirations" runat="server"
    > Height="100%" Width="100%">
    > <asp:TableRow runat="server" Height="20px">
    > <asp:TableCell runat="server"
    > BackColor="CornflowerBlue" Font-Names="Arial"
    > Font-Size="Larger"
    > ForeColor="White">Lease
    > Expirations Next 90 Days
    > </asp:TableCell>
    > </asp:TableRow>
    > <asp:TableRow runat="server">
    > <asp:TableCell runat="server"
    > Font-Names="Arial">No servers are going end of lease in the next 90
    > days
    > <asp:GridView ID="dgData"
    > runat="server"
    > AllowPaging="True"
    > AutoGenerateColumns="False"
    > EnableSortingAndPagingCallbacks="True"
    > Font-Names="Arial"
    > Font-Size="Medium" PageSize="4">
    > <PagerSettings Position="Top"
    > />
    > <Columns>
    > <asp:ButtonField
    > DataTextField="server_name" HeaderText="Server Name"
    > ShowHeader="True"
    > Text="Button" />
    > <asp:BoundField
    > DataField="exp_lease" DataFormatString="{0:MM/dd/yyyy}"
    >
    > HeaderText="Expiration" />
    > <asp:BoundField
    > DataField="status" HeaderText="Status" />
    > <asp:BoundField
    > DataField="Server_Id" HeaderText="Server Id" Visible="False" />
    > </Columns>
    > <PagerStyle
    > BackColor="CornflowerBlue" Font-Bold="True" Font-Names="Tahoma"
    > Font-Size="Small"
    > ForeColor="White" />
    > <HeaderStyle
    > BackColor="CornflowerBlue" Font-Names="Arial" Font-Size="Medium"
    > ForeColor="White" />
    > <AlternatingRowStyle
    > BackColor="Cornsilk" Font-Names="Arial"
    > Font-Size="Medium" />
    > </asp:GridView>
    > </asp:TableCell>
    > </asp:TableRow>
    > </asp:Table>
    > </asp:TableCell>
    > </asp:TableRow>
    > </asp:Table>
    > Thanks for taking a look
    >
    > Matt
    >
    > "David R. Longnecker" <> wrote in message
    > news:...
    > Matt-
    > Could you post an example of your code? As you mentioned--it should
    > work. I tried reproducing the code and didn't have any trouble:
    >
    > aspx page:
    >
    > <asp:Table ID="tbl" runat="server" GridLines="Both">
    > <asp:TableRow>
    > <asp:TableCell Text="Hello, world!" /><asp:TableCell
    > Text="Cell 2"
    > />
    > </asp:TableRow>
    > <asp:TableRow>
    > <asp:TableCell ColumnSpan="2">
    > <p>GridView!</p>
    > <asp:GridView ID="gv" runat="server" />
    > </asp:TableCell>
    > </asp:TableRow>
    > </asp:Table>
    > code-behind:
    >
    > protected void Page_Load(object sender, EventArgs e)
    > {
    > gv.DataSource = new
    > NorthwindDataContext().Products.ToList();
    > gv.DataBind();
    > }
    > See attached image for the results.
    >
    > HTH.
    >
    > -dl
    >
    > --
    > David R. Longnecker
    > http://blog.tiredstudent.com
    >> I'm using VS2008, and I need to put a gridview into a table cell (an
    >> asp table). I made the gridview and set it all up outside the table,
    >> then I edit the HTML and move the gridview into the table cell it
    >> should go into, but then it doesn't show no matter what I do. It's
    >> like it's invisible. If I drag the HTML that describes the gridview
    >> out of the table cell and on its own, the gridview shows fine.
    >>
    >> Is there some problem with putting a gridview in a table cell
    >> (unlikely) or can someone tell me what the trick is?
    >>
    >> Matt
    >>
    mattd1, Mar 26, 2008
    #3
  4. mattd1

    mattd1 Guest

    And the other thing that was confusing is when you are editing the page in
    the page designer the gridview I don't have in a table shows up, but the one
    I did have in the grid didn't show. That really confused me. Then when I run
    the app I don't load any data into the grid not in the table and that one
    disappears during runtime.

    Confusing

    Matt

    "mattd1" <> wrote in message
    news:ub%...
    > So, I see the problem. I didn't realize that .net hid the grid if there
    > was no data. I didn't have that problem in 2005 (I'm translating the
    > project to 2008) because I used absolute positioning instead of tables,
    > and as I recall the datagrid in 2005 showed regardless..
    >
    > You asked a couple times about the datasource, so you were correctly
    > focused on the problem. Thanks a million for your help. I am moving from
    > WinForms to web based for this app and I don't know all these webby
    > quirks.
    >
    > Thanks again David. You were very helpful.
    >
    > Matt
    >
    > "David R. Longnecker" <> wrote in message
    > news:...
    > Matt-
    >
    > I copied the HTML you have below into a new aspx page, loaded up Northwind
    > and picked out some similar data fields to yours, and it worked like a
    > champ.
    >
    > I've attached an image of the results and a text file with the code I used
    > to generate it (I had to change a few of the Ids when they copied over as
    > the copy process plugged in Ids for your TableCells that didn't have them
    > and duplicates cropped up).
    >
    > Code behind:
    >
    > protected void Page_Load(object sender, EventArgs e)
    > {
    > dgData.DataSource =
    > new NorthwindDataContext()
    > .Products
    > .Select(x => new { x.ProductID, x.ProductName,
    > x.Discontinued });
    > dgData.DataBind();
    > }
    >
    > How are you loading data into your grid view? Code-behind? DataSource
    > control?
    >
    > -dl
    >
    > --
    > David R. Longnecker
    > http://blog.tiredstudent.com
    >
    >> Hi David -
    >>
    >> Here's the HTML. I haven't even started with the codebehind yet.
    >>
    >> <asp:Table ID="tblSearchAndLeaseExpirations" runat="server"
    >> Height="167px"
    >> Width="100%" BorderColor="Black" BorderStyle="Solid"
    >> BorderWidth="1px"
    >> CellPadding="10" GridLines="Both">
    >> <asp:TableRow runat="server" Width="100%">
    >> <asp:TableCell runat="server" Width="50%" ID="tclSearch">
    >> <asp:Table ID="tblSearchBox" runat="server"
    >> BackColor="Cornsilk" Width="100%"
    >> BorderColor="Black" BorderStyle="Solid"
    >> BorderWidth="1px">
    >> <asp:TableRow ID="TableRow1" runat="server">
    >> <asp:TableCell ID="TableCell1" runat="server"
    >> BackColor="CornflowerBlue" Font-Bold="True"
    >> Font-Names="Arial"
    >> ForeColor="White">Search for
    >> servers</asp:TableCell>
    >> </asp:TableRow>
    >> <asp:TableRow ID="TableRow2" runat="server">
    >> <asp:TableCell ID="TableCell2" runat="server"
    >> Font-Names="Tahoma" Font-Size="Smaller">Type a
    >> server name or select one from the list.
    >> Wildcards
    >> (* and ?) are supported</asp:TableCell>
    >> </asp:TableRow>
    >> <asp:TableRow ID="TableRow3" runat="server">
    >> <asp:TableCell ID="tclErrorMessage"
    >> runat="server"
    >> Font-Names="Tahoma" Font-Size="Smaller"
    >> ForeColor="Red">That is not a valid
    >> server.
    >> Please enter another name.</asp:TableCell>
    >> </asp:TableRow>
    >> <asp:TableRow ID="TableRow4" runat="server">
    >> <asp:TableCell ID="TableCell4" runat="server">
    >> <asp:TextBox ID="txtServerName"
    >> runat="server"
    >> Width="75%">*</asp:TextBox>
    >> </asp:TableCell>
    >> </asp:TableRow>
    >> </asp:Table>
    >> <asp:Table ID="tblSearchBoxControls" runat="server"
    >> Width="100%" BorderColor="Black"
    >> BorderStyle="Solid" BorderWidth="1px">
    >> <asp:TableRow ID="TableRow5" runat="server">
    >> <asp:TableCell ID="TableCell5" runat="server"
    >> BackColor="Cornsilk" Width="50%">
    >> <asp:CheckBox ID="chkSearchAll"
    >> runat="server"
    >> BackColor="Cornsilk"
    >> Font-Names="Tahoma"
    >> Font-Size="Smaller"
    >> Text="Search All"/>
    >> </asp:TableCell>
    >> <asp:TableCell ID="TableCell6" runat="server"
    >> BackColor="Cornsilk" HorizontalAlign="Right">
    >> <asp:Button ID="cmdGetServer"
    >> runat="server"
    >> Font-Names="Tahoma"
    >> Font-Size="Smaller" Text="Get Server"
    >> Width="76" Height="21" />
    >> </asp:TableCell>
    >> </asp:TableRow>
    >> </asp:Table>
    >> </asp:TableCell>
    >>
    >> <asp:TableCell runat="server" Width="50%"
    >> ID="tclLeaseExpiration">
    >> <asp:Table ID="tblLeaseExpirations" runat="server"
    >> Height="100%" Width="100%">
    >> <asp:TableRow runat="server" Height="20px">
    >> <asp:TableCell runat="server"
    >> BackColor="CornflowerBlue" Font-Names="Arial"
    >> Font-Size="Larger"
    >> ForeColor="White">Lease
    >> Expirations Next 90 Days
    >> </asp:TableCell>
    >> </asp:TableRow>
    >> <asp:TableRow runat="server">
    >> <asp:TableCell runat="server"
    >> Font-Names="Arial">No servers are going end of lease in the next 90
    >> days
    >> <asp:GridView ID="dgData"
    >> runat="server"
    >> AllowPaging="True"
    >> AutoGenerateColumns="False"
    >> EnableSortingAndPagingCallbacks="True"
    >> Font-Names="Arial"
    >> Font-Size="Medium" PageSize="4">
    >> <PagerSettings Position="Top"
    >> />
    >> <Columns>
    >> <asp:ButtonField
    >> DataTextField="server_name" HeaderText="Server Name"
    >> ShowHeader="True"
    >> Text="Button" />
    >> <asp:BoundField
    >> DataField="exp_lease" DataFormatString="{0:MM/dd/yyyy}"
    >>
    >> HeaderText="Expiration" />
    >> <asp:BoundField
    >> DataField="status" HeaderText="Status" />
    >> <asp:BoundField
    >> DataField="Server_Id" HeaderText="Server Id" Visible="False" />
    >> </Columns>
    >> <PagerStyle
    >> BackColor="CornflowerBlue" Font-Bold="True" Font-Names="Tahoma"
    >> Font-Size="Small"
    >> ForeColor="White" />
    >> <HeaderStyle
    >> BackColor="CornflowerBlue" Font-Names="Arial" Font-Size="Medium"
    >> ForeColor="White" />
    >> <AlternatingRowStyle
    >> BackColor="Cornsilk" Font-Names="Arial"
    >> Font-Size="Medium" />
    >> </asp:GridView>
    >> </asp:TableCell>
    >> </asp:TableRow>
    >> </asp:Table>
    >> </asp:TableCell>
    >> </asp:TableRow>
    >> </asp:Table>
    >> Thanks for taking a look
    >>
    >> Matt
    >>
    >> "David R. Longnecker" <> wrote in message
    >> news:...
    >> Matt-
    >> Could you post an example of your code? As you mentioned--it should
    >> work. I tried reproducing the code and didn't have any trouble:
    >>
    >> aspx page:
    >>
    >> <asp:Table ID="tbl" runat="server" GridLines="Both">
    >> <asp:TableRow>
    >> <asp:TableCell Text="Hello, world!" /><asp:TableCell
    >> Text="Cell 2"
    >> />
    >> </asp:TableRow>
    >> <asp:TableRow>
    >> <asp:TableCell ColumnSpan="2">
    >> <p>GridView!</p>
    >> <asp:GridView ID="gv" runat="server" />
    >> </asp:TableCell>
    >> </asp:TableRow>
    >> </asp:Table>
    >> code-behind:
    >>
    >> protected void Page_Load(object sender, EventArgs e)
    >> {
    >> gv.DataSource = new
    >> NorthwindDataContext().Products.ToList();
    >> gv.DataBind();
    >> }
    >> See attached image for the results.
    >>
    >> HTH.
    >>
    >> -dl
    >>
    >> --
    >> David R. Longnecker
    >> http://blog.tiredstudent.com
    >>> I'm using VS2008, and I need to put a gridview into a table cell (an
    >>> asp table). I made the gridview and set it all up outside the table,
    >>> then I edit the HTML and move the gridview into the table cell it
    >>> should go into, but then it doesn't show no matter what I do. It's
    >>> like it's invisible. If I drag the HTML that describes the gridview
    >>> out of the table cell and on its own, the gridview shows fine.
    >>>
    >>> Is there some problem with putting a gridview in a table cell
    >>> (unlikely) or can someone tell me what the trick is?
    >>>
    >>> Matt
    >>>

    >
    >
    mattd1, Mar 26, 2008
    #4
  5. Good to hear you worked it out. I'd recommend tossing a EmptyDataTemplate
    into your GridView--just for such an occassion.

    <asp:GridView ...stuff here>

    <EmptyDataTemplate>Sorry, no data here!</EmptyDataTemplate>

    </asp:GridView>

    That way, when it's empty, it'll spit that text out instead.

    Now, AFAIK, it's not "hiding" the GridView, it's being extremely percise--since
    the designer doesn't have a data source to render columns off of (since we're
    loading data in code-behind), it assumes that there isn't any data. I'm
    honestly not sure if that's a different action that in 2005 or 2003--I don't
    think so. Unfortunately, I tend to stick to Source or code-behind view,
    so quirks in the Designer go right over my head.

    Addressing your other question (in the other thread):

    This may be caused by using the asp:Table... is there a reason for using
    a .NET control rather than just HTML? asp:Table generates HTML, but, at
    least when I go into the designer, I can't manipulate controls inside the
    TableCell(s). Using standard HTML, you should be able to drop/drag and manage
    the controls inside.

    Another here probably has more experience with that control and can provide
    some insight--it may be behavior by design.

    HTH.

    -dl

    --
    David R. Longnecker
    http://blog.tiredstudent.com

    > So, I see the problem. I didn't realize that .net hid the grid if
    > there was no data. I didn't have that problem in 2005 (I'm translating
    > the project to 2008) because I used absolute positioning instead of
    > tables, and as I recall the datagrid in 2005 showed regardless..
    >
    > You asked a couple times about the datasource, so you were correctly
    > focused on the problem. Thanks a million for your help. I am moving
    > from WinForms to web based for this app and I don't know all these
    > webby quirks.
    >
    > Thanks again David. You were very helpful.
    >
    > Matt
    >
    > "David R. Longnecker" <> wrote in message
    > news:...
    > Matt-
    > I copied the HTML you have below into a new aspx page, loaded up
    > Northwind and picked out some similar data fields to yours, and it
    > worked like a champ.
    >
    > I've attached an image of the results and a text file with the code I
    > used to generate it (I had to change a few of the Ids when they copied
    > over as the copy process plugged in Ids for your TableCells that
    > didn't have them and duplicates cropped up).
    >
    > Code behind:
    >
    > protected void Page_Load(object sender, EventArgs e)
    > {
    > dgData.DataSource =
    > new NorthwindDataContext()
    > .Products
    > .Select(x => new { x.ProductID, x.ProductName,
    > x.Discontinued });
    > dgData.DataBind();
    > }
    > How are you loading data into your grid view? Code-behind?
    > DataSource control?
    >
    > -dl
    >
    > --
    > David R. Longnecker
    > http://blog.tiredstudent.com
    >> Hi David -
    >>
    >> Here's the HTML. I haven't even started with the codebehind yet.
    >>
    >> <asp:Table ID="tblSearchAndLeaseExpirations" runat="server"
    >> Height="167px"
    >> Width="100%" BorderColor="Black" BorderStyle="Solid"
    >> BorderWidth="1px"
    >> CellPadding="10" GridLines="Both">
    >> <asp:TableRow runat="server" Width="100%">
    >> <asp:TableCell runat="server" Width="50%" ID="tclSearch">
    >> <asp:Table ID="tblSearchBox" runat="server"
    >> BackColor="Cornsilk" Width="100%"
    >> BorderColor="Black" BorderStyle="Solid"
    >> BorderWidth="1px">
    >> <asp:TableRow ID="TableRow1" runat="server">
    >> <asp:TableCell ID="TableCell1" runat="server"
    >> BackColor="CornflowerBlue" Font-Bold="True"
    >> Font-Names="Arial"
    >> ForeColor="White">Search for
    >> servers</asp:TableCell>
    >> </asp:TableRow>
    >> <asp:TableRow ID="TableRow2" runat="server">
    >> <asp:TableCell ID="TableCell2" runat="server"
    >> Font-Names="Tahoma" Font-Size="Smaller">Type a
    >> server name or select one from the list.
    >> Wildcards
    >> (* and ?) are supported</asp:TableCell>
    >> </asp:TableRow>
    >> <asp:TableRow ID="TableRow3" runat="server">
    >> <asp:TableCell ID="tclErrorMessage"
    >> runat="server"
    >> Font-Names="Tahoma" Font-Size="Smaller"
    >> ForeColor="Red">That is not a valid
    >> server.
    >> Please enter another name.</asp:TableCell>
    >> </asp:TableRow>
    >> <asp:TableRow ID="TableRow4" runat="server">
    >> <asp:TableCell ID="TableCell4" runat="server">
    >> <asp:TextBox ID="txtServerName"
    >> runat="server"
    >> Width="75%">*</asp:TextBox>
    >> </asp:TableCell>
    >> </asp:TableRow>
    >> </asp:Table>
    >> <asp:Table ID="tblSearchBoxControls" runat="server"
    >> Width="100%" BorderColor="Black"
    >> BorderStyle="Solid" BorderWidth="1px">
    >> <asp:TableRow ID="TableRow5" runat="server">
    >> <asp:TableCell ID="TableCell5" runat="server"
    >> BackColor="Cornsilk" Width="50%">
    >> <asp:CheckBox ID="chkSearchAll"
    >> runat="server"
    >> BackColor="Cornsilk"
    >> Font-Names="Tahoma"
    >> Font-Size="Smaller"
    >> Text="Search All"/>
    >> </asp:TableCell>
    >> <asp:TableCell ID="TableCell6" runat="server"
    >> BackColor="Cornsilk" HorizontalAlign="Right">
    >> <asp:Button ID="cmdGetServer"
    >> runat="server"
    >> Font-Names="Tahoma"
    >> Font-Size="Smaller" Text="Get Server"
    >> Width="76" Height="21" />
    >> </asp:TableCell>
    >> </asp:TableRow>
    >> </asp:Table>
    >> </asp:TableCell>
    >> <asp:TableCell runat="server" Width="50%"
    >> ID="tclLeaseExpiration">
    >> <asp:Table ID="tblLeaseExpirations" runat="server"
    >> Height="100%" Width="100%">
    >> <asp:TableRow runat="server" Height="20px">
    >> <asp:TableCell runat="server"
    >> BackColor="CornflowerBlue" Font-Names="Arial"
    >> Font-Size="Larger"
    >> ForeColor="White">Lease
    >> Expirations Next 90 Days
    >> </asp:TableCell>
    >> </asp:TableRow>
    >> <asp:TableRow runat="server">
    >> <asp:TableCell runat="server"
    >> Font-Names="Arial">No servers are going end of lease in the next 90
    >> days
    >> <asp:GridView ID="dgData"
    >> runat="server"
    >> AllowPaging="True"
    >> AutoGenerateColumns="False"
    >> EnableSortingAndPagingCallbacks="True"
    >> Font-Names="Arial"
    >> Font-Size="Medium" PageSize="4">
    >> <PagerSettings Position="Top"
    >> />
    >> <Columns>
    >> <asp:ButtonField
    >> DataTextField="server_name" HeaderText="Server Name"
    >> ShowHeader="True"
    >> Text="Button" />
    >> <asp:BoundField
    >> DataField="exp_lease" DataFormatString="{0:MM/dd/yyyy}"
    >> HeaderText="Expiration" />
    >> <asp:BoundField
    >> DataField="status" HeaderText="Status" />
    >> <asp:BoundField
    >> DataField="Server_Id" HeaderText="Server Id" Visible="False" />
    >> </Columns>
    >> <PagerStyle
    >> BackColor="CornflowerBlue" Font-Bold="True" Font-Names="Tahoma"
    >> Font-Size="Small"
    >> ForeColor="White" />
    >> <HeaderStyle
    >> BackColor="CornflowerBlue" Font-Names="Arial" Font-Size="Medium"
    >> ForeColor="White" />
    >> <AlternatingRowStyle
    >> BackColor="Cornsilk" Font-Names="Arial"
    >> Font-Size="Medium" />
    >> </asp:GridView>
    >> </asp:TableCell>
    >> </asp:TableRow>
    >> </asp:Table>
    >> </asp:TableCell>
    >> </asp:TableRow>
    >> </asp:Table>
    >> Thanks for taking a look
    >> Matt
    >>
    >> "David R. Longnecker" <> wrote in message
    >> news:...
    >> Matt-
    >> Could you post an example of your code? As you mentioned--it should
    >> work. I tried reproducing the code and didn't have any trouble:
    >> aspx page:
    >>
    >> <asp:Table ID="tbl" runat="server" GridLines="Both">
    >> <asp:TableRow>
    >> <asp:TableCell Text="Hello, world!" /><asp:TableCell
    >> Text="Cell 2"
    >> />
    >> </asp:TableRow>
    >> <asp:TableRow>
    >> <asp:TableCell ColumnSpan="2">
    >> <p>GridView!</p>
    >> <asp:GridView ID="gv" runat="server" />
    >> </asp:TableCell>
    >> </asp:TableRow>
    >> </asp:Table>
    >> code-behind:
    >> protected void Page_Load(object sender, EventArgs e)
    >> {
    >> gv.DataSource = new
    >> NorthwindDataContext().Products.ToList();
    >> gv.DataBind();
    >> }
    >> See attached image for the results.
    >> HTH.
    >>
    >> -dl
    >>
    >> --
    >> David R. Longnecker
    >> http://blog.tiredstudent.com
    >>> I'm using VS2008, and I need to put a gridview into a table cell (an
    >>> asp table). I made the gridview and set it all up outside the table,
    >>> then I edit the HTML and move the gridview into the table cell it
    >>> should go into, but then it doesn't show no matter what I do. It's
    >>> like it's invisible. If I drag the HTML that describes the gridview
    >>> out of the table cell and on its own, the gridview shows fine.
    >>>
    >>> Is there some problem with putting a gridview in a table cell
    >>> (unlikely) or can someone tell me what the trick is?
    >>>
    >>> Matt
    >>>
    David R. Longnecker, Mar 26, 2008
    #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. David Williams
    Replies:
    2
    Views:
    1,122
    Jacob Yang [MSFT]
    Aug 12, 2003
  2. Nalaka

    GridView in a GridView

    Nalaka, Nov 11, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    6,606
    Nalaka
    Dec 5, 2005
  3. Replies:
    3
    Views:
    5,111
  4. Rio
    Replies:
    4
    Views:
    1,187
  5. =?Utf-8?B?bWdvbnphbGVzMw==?=

    GridView Hierarchical View - Gridview in Gridview

    =?Utf-8?B?bWdvbnphbGVzMw==?=, May 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    17,962
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    May 9, 2006
Loading...

Share This Page