JosephRalph
asked on
How to apply an auto format style to a data list
Hi,
I have a datalist with four columns, I want to apply an auto format style to it but it is not working right.
the source code of the datalist before the style is apply is
<asp:datalist id="DLServicios" runat="server" >
<HeaderTemplate>
<TD># Parcelas</TD>
<TD>Fecha de Envio</TD>
<TD>Numero Control</TD>
<TD>Link</TD>
</HeaderTemplate>
<ItemTemplate>
<TD><%# DataBinder.Eval ( Container.DataItem, "Parcelasoficiales") %></TD>
<td><%# DataBinder.Eval ( Container.DataItem, "EnviadoRegional") %></td>
<td><%# DataBinder.Eval ( Container.DataItem, "NumControl") %></td>
<td><a href='DetalleServicio.aspx ?id=<%# DataBinder.Eval (Container.DataItem, "ID_Servicio" ) %>'><%# DataBinder.Eval (Container.DataItem, "ID_Servicio" ) %></a></td>
</ItemTemplate>
</asp:datalist>
by seeing the td tags you me know what i'm trying to do.
and the source code after applying the style is
<asp:datalist id="DLServicios" runat="server" Width="424px" GridLines="Both" CellSpacing="2" CellPadding="3"
BorderColor="#DEBA84" BorderStyle="None" BackColor="#DEBA84" BorderWidth="1px">
<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#738A9C"></Sele ctedItemSt yle>
<HeaderTemplate>
<TD># Parcelas</TD>
<TD>Fecha de Envio</TD>
<TD>Numero Control</TD>
<TD>Link</TD>
</HeaderTemplate>
<FooterStyle ForeColor="#8C4510" BackColor="#F7DFB5"></Foot erStyle>
<ItemStyle ForeColor="#8C4510" BackColor="#FFF7E7"></Item Style>
<ItemTemplate>
<TD><%# DataBinder.Eval ( Container.DataItem, "Parcelasoficiales") %></TD>
<td><%# DataBinder.Eval ( Container.DataItem, "EnviadoRegional") %></td>
<td><%# DataBinder.Eval ( Container.DataItem, "NumControl") %></td>
<td><a href='DetalleServicio.aspx ?id=<%# DataBinder.Eval (Container.DataItem, "ID_Servicio" ) %>'><%# DataBinder.Eval (Container.DataItem, "ID_Servicio" ) %></a></td>
</ItemTemplate>
<HeaderStyle Font-Bold="True" BorderWidth="5px" ForeColor="White" BackColor="#A55129"></Head erStyle>
</asp:datalist>
I have a datalist with four columns, I want to apply an auto format style to it but it is not working right.
the source code of the datalist before the style is apply is
<asp:datalist id="DLServicios" runat="server" >
<HeaderTemplate>
<TD># Parcelas</TD>
<TD>Fecha de Envio</TD>
<TD>Numero Control</TD>
<TD>Link</TD>
</HeaderTemplate>
<ItemTemplate>
<TD><%# DataBinder.Eval ( Container.DataItem, "Parcelasoficiales") %></TD>
<td><%# DataBinder.Eval ( Container.DataItem, "EnviadoRegional") %></td>
<td><%# DataBinder.Eval ( Container.DataItem, "NumControl") %></td>
<td><a href='DetalleServicio.aspx
</ItemTemplate>
</asp:datalist>
by seeing the td tags you me know what i'm trying to do.
and the source code after applying the style is
<asp:datalist id="DLServicios" runat="server" Width="424px" GridLines="Both" CellSpacing="2" CellPadding="3"
BorderColor="#DEBA84" BorderStyle="None" BackColor="#DEBA84" BorderWidth="1px">
<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#738A9C"></Sele
<HeaderTemplate>
<TD># Parcelas</TD>
<TD>Fecha de Envio</TD>
<TD>Numero Control</TD>
<TD>Link</TD>
</HeaderTemplate>
<FooterStyle ForeColor="#8C4510" BackColor="#F7DFB5"></Foot
<ItemStyle ForeColor="#8C4510" BackColor="#FFF7E7"></Item
<ItemTemplate>
<TD><%# DataBinder.Eval ( Container.DataItem, "Parcelasoficiales") %></TD>
<td><%# DataBinder.Eval ( Container.DataItem, "EnviadoRegional") %></td>
<td><%# DataBinder.Eval ( Container.DataItem, "NumControl") %></td>
<td><a href='DetalleServicio.aspx
</ItemTemplate>
<HeaderStyle Font-Bold="True" BorderWidth="5px" ForeColor="White" BackColor="#A55129"></Head
</asp:datalist>
ASKER
nop, the style is not working
Do you see the control formatting in VS.NET?
-Nauman.
-Nauman.
ASKER
yes,
the style appear but like in a column in front of the others columns
style # Parcelas Fecha de Envio Numero Control Link
style datatabound datatabound datatabound datatabound
in other words the first column has the style but the others parcelas, fecha, numero dosen't.
hope you understand my lazy explanation.
the style appear but like in a column in front of the others columns
style # Parcelas Fecha de Envio Numero Control Link
style datatabound datatabound datatabound datatabound
in other words the first column has the style but the others parcelas, fecha, numero dosen't.
hope you understand my lazy explanation.
ASKER
look at the html code generated by the control
<table id="DLServicios" cellspacing="2" cellpadding="3" rules="all" bordercolor="#DEBA84" border="1" style="background-color:#D EBA84;bord er-color:# DEBA84;bor der-width: 1px;border -style:Non e;width:42 4px;">
<tr>
<td style="color:White;backgro und-color: #A55129;fo nt-weight: bold;">
<TD># Parcelas</TD>
<TD>Fecha de Envio</TD>
<TD>Numero Control</TD>
<TD>Link</TD>
</td>
</tr><tr>
<td style="color:#8C4510;backg round-colo r:#FFF7E7; ">
<TD></TD>
<td>4/24/2002 12:00:00 AM</td>
<td>2006-5431</td>
<td><a href='DetalleServicio.aspx ?id=9'>9</ a></td>
</td>
</tr>
</table>
by looking at this is obvious why it doesnt work, but how to work around this problem.
<table id="DLServicios" cellspacing="2" cellpadding="3" rules="all" bordercolor="#DEBA84" border="1" style="background-color:#D
<tr>
<td style="color:White;backgro
<TD># Parcelas</TD>
<TD>Fecha de Envio</TD>
<TD>Numero Control</TD>
<TD>Link</TD>
</td>
</tr><tr>
<td style="color:#8C4510;backg
<TD></TD>
<td>4/24/2002 12:00:00 AM</td>
<td>2006-5431</td>
<td><a href='DetalleServicio.aspx
</td>
</tr>
</table>
by looking at this is obvious why it doesnt work, but how to work around this problem.
ASKER
the solution I found was
<HeaderTemplate>
<TR style="color:White;backgro und-color: #A55129;fo nt-weight: bold;">
<TD># Parcelas</TD>
<TD>Fecha de Envio</TD>
<TD>Numero Control</TD>
<TD>Link</TD>
</TR>
</HeaderTemplate>
<ItemTemplate>
<tr style="color:#8C4510;backg round-colo r:#FFF7E7; ">
<TD><%# DataBinder.Eval ( Container.DataItem, "Parcelasoficiales") %></TD>
<td><%# DataBinder.Eval ( Container.DataItem, "EnviadoRegional") %></td>
<td><%# DataBinder.Eval ( Container.DataItem, "NumControl") %></td>
<td><a href='DetalleServicio.aspx ?id=<%# DataBinder.Eval (Container.DataItem, "ID_Servicio" ) %>'><%# DataBinder.Eval (Container.DataItem, "ID_Servicio" ) %></a></td>
</tr>
</ItemTemplate>
In other words put the td inside a tr.
<HeaderTemplate>
<TR style="color:White;backgro
<TD># Parcelas</TD>
<TD>Fecha de Envio</TD>
<TD>Numero Control</TD>
<TD>Link</TD>
</TR>
</HeaderTemplate>
<ItemTemplate>
<tr style="color:#8C4510;backg
<TD><%# DataBinder.Eval ( Container.DataItem, "Parcelasoficiales") %></TD>
<td><%# DataBinder.Eval ( Container.DataItem, "EnviadoRegional") %></td>
<td><%# DataBinder.Eval ( Container.DataItem, "NumControl") %></td>
<td><a href='DetalleServicio.aspx
</tr>
</ItemTemplate>
In other words put the td inside a tr.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
-Nauman.