?
Solved

Formatting templates in a datalist not working - please help

Posted on 2004-07-30
7
Medium Priority
?
307 Views
Last Modified: 2008-02-26
Hi There

I'm trying to format the display of my header in this datalist and I can't seem to apply header or item style to any templates, what am I doing wrong?

Sean

      <asp:DataList id="modify_listings"
   runat="server"
   BorderColor="#DEBA84" BorderStyle="None"
   CellSpacing="2" BackColor="#DEBA84"
   CellPadding="3" GridLines="Both" BorderWidth="1px"
   AlternatingItemStyle-BackColor="pink">
               
                        <AlternatingItemStyle Font-Underline="True" Font-Bold="True" BackColor="Red"></AlternatingItemStyle>
                        <ItemStyle Font-Names="Arial Narrow" Font-Bold="True"></ItemStyle>
                        <HeaderStyle Font-Bold="True" BorderColor="Green"></HeaderStyle>
             
               
<HeaderTemplate><tr><td>Modify</td><td>Price</td><td>Manufacturer</td><td>Listed Date</td><td>Listing</td><td>Status</td><td>Sold Items</td></tr></HeaderTemplate>
            
0
Comment
Question by:bullrout
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 9

Expert Comment

by:crescendo
ID: 11683187
What are you using to write your app? Most visual tools (Web Matrix, Visual Studio etc) have a built in facility for setting the styles on headers/footers etc, which is much easier than coding your own HTML.
0
 
LVL 9

Assisted Solution

by:crescendo
crescendo earned 660 total points
ID: 11685107
Looking at what you've shown, there's no  </asp:DataList> tag. Was that omitted when you posted the question, or is it missing in your code?
0
 
LVL 17

Assisted Solution

by:AerosSaga
AerosSaga earned 660 total points
ID: 11685517
just put the style sheet in the header of the aspx page, and set the css property of the datalist to the name of the stylesheet.

Regards,

Aeros
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 5

Author Comment

by:bullrout
ID: 11686302
Hi There,

The  </asp:DataList> is there I must have missed it with the cut & paste. I will try the style sheet idea, thanks.

sean
0
 
LVL 5

Author Comment

by:bullrout
ID: 11687041
Hi There,

I am still having an issue the formatting of my datalist, how can I get the container items to appear as columns? Do I have to use a table row & td tags or are there specific properties that I can apply to the datalist in order to format it like below? I need to use the alternatingitem style in my list and it does not seem to work when I use table tags in the itemtemplates.

Sean

<tr><td> col1</td><td> col2</td><td> col3</td><td> col4</td></tr>
                                    
<ItemTemplate>
                                          
                                <asp:HyperLink id="HyperLink3" style="font-size:xxsmall" Text='Modify' NavigateUrl='<%# "edit_listings.aspx?ListingID=" & DataBinder.Eval(Container.DataItem, "ListingID")%>' runat="server" /><br />
                 
                                <%# DataBinder.Eval(Container.DataItem, "listprice","{0:c}")%><br />
                 
                                <%# DataBinder.Eval(Container.DataItem, "manufacturer") %><br />
                             
                                <%# DataBinder.Eval(Container.DataItem, "listeddate","{0:dd-MM-yy}") %><br />
                        
                                <%# DataBinder.Eval(Container.DataItem, "formname") %><br />
                                <%# DataBinder.Eval(Container.DataItem, "status") %><br />
                               <asp:HyperLink id="HyperLink1" style="font-size:xxsmall" Text='Item Sold?' NavigateUrl='<%# "processrequest.aspx?I=1&ListingID=" & DataBinder.Eval(Container.DataItem, "ListingID")%>' runat="server" />
                                          
                                    </ItemTemplate>
                  </asp:DataList>
0
 
LVL 21

Accepted Solution

by:
tovvenki earned 680 total points
ID: 11691274
Hi,
try like the following code snippet
<asp:DataList ID="dtlPublishers" Runat="server" ItemStyle-BorderWidth="1">
  <HeaderTemplate>
    <table width="760px" cellspacing="0" cellpadding="0">
      <tr class="tablehead">
        <th align="left" width="25%">Name</th>
        <th align="left" width="25%">City</th>
        <th align="left" width="25%">State</th>
        <th align="left" width="25%">Country</th>
      </tr>
    </table>
  </HeaderTemplate>
  <ItemTemplate>
    <table width="760px" cellspacing="0" cellpadding="0">
      <tr class="tablebody">
        <td width="25%"><%# DataBinder.Eval(Container.DataItem, "pub_name") %></td>
        <td width="25%"><%# DataBinder.Eval(Container.DataItem, "city") %></td>
        <td width="25%"><%# DataBinder.Eval(Container.DataItem, "State") %></td>
        <td width="25%"><%# DataBinder.Eval(Container.DataItem, "Country") %></td>
      </tr>
    </table>
  </ItemTemplate>
</asp:DataList>

Hope that this helps you

regards,
venki
0
 
LVL 5

Author Comment

by:bullrout
ID: 11694837
I ended up using a datagrid, I stupidly assumed that because I had custom paging that a datagrid did not support this method. I am only relatively new to asp .net and I guess the only way you learn is by doing!

Thanks for all the help anyway everyone.

Sean
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question