Jump to content

Datalist - Stylesheets

- - - - -

  • Please log in to reply
4 replies to this topic

#1
Guest_Silverback_*

Guest_Silverback_*
  • Guests
I am fairly new to .Net so my appologises if this is a stupid question:

I have just created a datalist with a dataset that is populated. I am having trouble getting the stylesheet parameters recognized.


                <asp:DataList ID="DataList1" runat="server" CssClass="DefaultClass">


works but it doesnt give me any flexibility for each row.

If I try the following it does not work:


                <asp:DataList ID="DataList1" runat="server" 

                       HeaderStyle-CssClass="DefaultHeaderRow" 

                       AlternatingItemStyle-CssClass="DefaultAltDetailRow" 

                       ItemStyle-CssClass="DefaultDetailRow" 

                       SelectedItemStyle-CssClass="DefaultDetailRow" 

                       OnSelectedIndexChanged="DataList1_SelectedIndexChanged" >


The properties are available in both Intellisense and on the Properties sheet. I have also found them in several code examples on the web.


I have also tried setting a base stylesheet and overriding each section with another stylesheet -


                <asp:DataList ID="DataList1" runat="server" CssClass="DefaultHeaderRowTest"

                    OnSelectedIndexChanged="DataList1_SelectedIndexChanged" >


                   <HeaderStyle CssClass="DefaultHeaderRow" />

                    <ItemStyle CssClass="DefaultAltDetailRow" />

                    <AlternatingItemStyle CssClass="DefaultAltDetailRow" />

                    <HeaderTemplate>



Normally I would just brute force add the parms manually but there are a lot of pages in this app.

Any help would be greatly appreciated by this newbie...
Thanks.
SB

EDIT: Added code tags around code so smilies don't appear

#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Have you tried just doing something like:


<asp:DataList id="DataList1"

runat="server"

cellpadding="2"

cellspacing="2"

borderstyle="inset"

backcolor="#e8e8e8"

width="100%"

headerstyle-font-name="Verdana"

headerstyle-font-size="12pt"

headerstyle-horizontalalign="center"

headerstyle-font-bold="True"

itemstyle-backcolor="#778899"

itemstyle-forecolor="#ffffff"

alternatingitemstyle-backcolor="#e8e8e8"

alternatingitemstyle-forecolor="#000000"

footerstyle-font-size="9pt"

footerstyle-font-italic="True">


EDIT: Moved to ASP.NET Forum for more responses

#3
Guest_Silverback_*

Guest_Silverback_*
  • Guests
Thanks Jordan but I dont think the issue was really whether they were in a stylesheet or not. I was able to get it close by adding tables within each template tag,
Ex.
<HeaderTemplate>
<table>
<tr >
<td width="21%" align="left">Domain</td>
<td width="20%" align="left">Pre2K</td>
<td width="40%" align="left">Scope</td>
<td width="18%" align="left">Members</td>
</tr>
<tr >
<td colspan="4">AD Path</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table>
....
</table>
</ItemTemplate>

The problem I now have is that I always have to play with the column widths in both the headers and the rows to get them to match up. By not being in the same table I couldnt get them to always be the same width.

Any other thoughts?
Thanks.
SB

#4
Blaze

Blaze

    Programmer

  • Members
  • PipPipPipPip
  • 117 posts
You can get them the same width if you use absolute pixel widths instead of percentages.

#5
merlintintin

merlintintin

    Newbie

  • Members
  • Pip
  • 1 posts
Hello,

I'm using this to manipulate ItemStyle and AlternatingItemStyle - it's working.
<asp:DataList ID="dataList" runat="server" CssClass="UCList" Width="960" ExtractTemplateRows="true" AlternatingItemStyle-CssClass="tableLineLast" ItemStyle-CssClass="tableLineFirst">
    ...
</asp:DataList>


stylesheet :
tr.tableLineFirst td {font-size: 11px; color: black; background-color: #F0F0F0; font-weight: normal; padding: 5px;  }
tr.tableLineLast td {font-size: 11px; color: black; background-color: #E4E5E3; font-weight: normal; padding: 5px; }


Hope this helps,

Edited by Alexander, 16 November 2010 - 03:56 AM.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users