Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > GridView in a table

Reply
Thread Tools

GridView in a table

 
 
mattd1
Guest
Posts: n/a
 
      03-25-2008
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


 
Reply With Quote
 
 
 
 
mattd1
Guest
Posts: n/a
 
      03-26-2008
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) .com...
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
>



 
Reply With Quote
 
 
 
 
mattd1
Guest
Posts: n/a
 
      03-26-2008
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
200 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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) .com...
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) .com...
> 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
>>



 
Reply With Quote
 
mattd1
Guest
Posts: n/a
 
      03-26-2008
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" <(E-Mail Removed)> wrote in message
news:ub%(E-Mail Removed)...
> 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 200 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) .com...
> 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" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed) .com...
>> 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
>>>

>
>



 
Reply With Quote
 
David R. Longnecker
Guest
Posts: n/a
 
      03-26-2008
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 200 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) .com...
> 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" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed) .com...
>> 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
>>>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView Hierarchical View - Gridview in Gridview =?Utf-8?B?bWdvbnphbGVzMw==?= ASP .Net 1 05-09-2006 06:48 PM
GridView in a GridView Nalaka ASP .Net 6 12-05-2005 05:48 PM
Gridview with combobox whose data is dependent on field in gridview wallermj@hotmail.com ASP .Net 3 11-21-2005 05:34 PM
Table/table rows/table data tag question? Rio HTML 4 11-05-2004 08:11 AM
Could not load type VTFixup Table from assembly Invalid token in v-table fix-up table. David Williams ASP .Net 2 08-12-2003 07:55 AM



Advertisments