Print Page | Close Window

Columns and Tables in ASP.Net

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=12117
Printed Date: 29 March 2026 at 12:51am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Columns and Tables in ASP.Net
Posted By: Misty
Subject: Columns and Tables in ASP.Net
Date Posted: 10 October 2004 at 10:19pm

I have a desire to be able to have a separate table for each record from a database. Please see http://www.switchboard.com/bin/cgidir.dll?mem=1301&FUNC=FORMATSEARCH&from=SBYP&C=Spas+%26+Hot+Tubs-Dealers&T=Tucson&S=AZ - http://www.switchboard.com/bin/cgidir.dll?mem=1301&FUNC= FORMATSEARCH&from=SBYP&C=Spas+%26+Hot+Tubs-Dealers&a mp;T=Tucson&S=AZ  for an example. I want tables with individual records. I have tried doing this with a datagrid, but I have failed.

There are two problems. The first problem is I want the name of the store to be on the header along with the web address. The second problem is I want all of the records to have a separate table.

Here's my code:

<ASP:DATAGRID id=dtgSpa runat="server"
Width="500px"
        ForeColor="Black"
        Font-Bold="True"
        Font-Size="8pt"
        Font-Name="Verdana, San-Serif"
        CellPadding="7"
        BorderWidth="1"
        BorderColor="#666666"
        BorderStyle="None"
        BackColor="White"
        ShowFooter="False"
        ShowHeader="True"

    AutoGenerateColumns="False"
    EnableViewState="False">

    <Columns>

 <asp:HyperLinkColumn HeaderText="SpaStoreName" (Not Happy with this) DataTextField="SpaStoreName" datanavigateurlformatstring="SpaStoreInfo.aspx?ID={0}" datanavigateurlfield="SpaStoreID" /> (I don't want this to go on the next line. I want all of this to be on the header.)
    </Columns>

    <HeaderStyle
        ForeColor="White"
        BorderStyle="Solid"
        BorderColor="#333333"
        BackColor="#333399" />

    <AlternatingItemStyle
        ForeColor="#333366"
        BorderColor="#333333"
        BackColor="#99ccff" />

    <ItemStyle
        Font-Bold="True"
        ForeColor="#000000" />

</ASP:DATAGRID>




Replies:
Posted By: Mart
Date Posted: 11 October 2004 at 2:02am
 Use a datalist control instead of a datagrid, do a google for examples, I haven't got time to write one sorry.


Posted By: Mart
Date Posted: 11 October 2004 at 2:52am
Heres a quick example:

<asp:datalist id="dlItems" runat="server" Width="100%">
<SeparatorTemplate>
<br>
</SeparatorTemplate>
<ItemTemplate>
<table cellpadding=0 cellspacing="1" class="Table" align=center>
<tr>
<td class="TableHeader"><%# Databinder.Eval(Container.DataItem, "Header") %></a>
</td>
</tr>
<tr>
<td class="TableHeader2">
</td>
</tr>
<tr>
<td class="TableContent">
<p>
<%# Databinder.Eval(Container.DataItem, "Content") %>
</p>
</td>
</tr>
</table>
</ItemTemplate>
</asp:datalist>


You bind it the same way as a datagrid, just change the column names etc. inside the ItemTemplate


Posted By: Misty
Date Posted: 11 October 2004 at 3:44pm

I have a datalist on my web page now. But I don't like the way the border is around my table. I have been trying to figure out how to fix this.

However, it looks like

http:// - Atlanta Spa Store

345 Main St.
Atlanta

I only want one line border around the table like http://www.switchboard.com/bin/cgidir.dll?mem=1301&FUNC=FORMATSEARCH&from=SBYP&C=Spas+%26+Hot+Tubs-Dealers&T=Tucson&S=AZ - http://www.switchboard.com/bin/cgidir.dll?mem=1301&FUNC= FORMATSEARCH&from=SBYP&C=Spas+%26+Hot+Tubs-Dealers&a mp;a mp;a mp;T=Tucson&S=AZ .

Here's my code:

<asp:datalist id="dtlSpa" runat="server" Width="400">
<SeparatorTemplate>
<br>
</SeparatorTemplate>
<ItemTemplate>
<table border=1 bordercolor="#ccccff" cellpadding=4 cellspacing="1" class="Table" width="400">
<tr>
<td bgcolor="#ccccff" class="TableHeader"><a href='<%# DataBinder.Eval (Container.DataItem, "SpaStoreID", "SpaStoreInfo.aspx?ID={0}") %>'> <%# Databinder.Eval(Container.DataItem, "SpaStoreName") %>
</a></td>
</tr>
<tr>
<td class="TableHeader2">
<p>
<%# Databinder.Eval(Container.DataItem, "Address") %>
<br>
<%# Databinder.Eval(Container.DataItem, "City") %>
</p>
</td>
</tr>
</table>
</ItemTemplate>

</asp:datalist>

 



Posted By: Mart
Date Posted: 11 October 2004 at 4:22pm
Just change the line after the ItemTemplate to:

<table border=1 bordercolor="#ccccff" cellpadding=4 cellspacing="0"


Posted By: Misty
Date Posted: 11 October 2004 at 4:28pm

I used the following code: <table border=1 bordercolor="#ccccff" cellpadding=4 cellspacing="0">

But I don't like the double borders that I have around my table. It looks something like:

http:/// - Atlanta Spa Store

345 Main St.
Atlanta

How do I get rid of one border? I only want one border.

Thanks,
Misty

 



Posted By: Mart
Date Posted: 11 October 2004 at 5:03pm
Set the cell padding to 0 aswell


Posted By: Misty
Date Posted: 11 October 2004 at 6:24pm

Mart,

Thank you! Yes, that worked. I must have missed this part about the cellspacing and cellpadding.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net