Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Columns and Tables in ASP.Net
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Columns and Tables in ASP.Net

 Post Reply Post Reply
Author
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post Topic: Columns and Tables in ASP.Net
    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&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>

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post 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

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&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>

 



Edited by Misty
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 11 October 2004 at 4:22pm
Just change the line after the ItemTemplate to:

<table border=1 bordercolor="#ccccff" cellpadding=4 cellspacing="0"
Back to Top
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post 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:

Atlanta Spa Store

345 Main St.
Atlanta

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

Thanks,
Misty

 

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 11 October 2004 at 5:03pm
Set the cell padding to 0 aswell
Back to Top
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post Posted: 11 October 2004 at 6:24pm

Mart,

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

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.