Link to home
Start Free TrialLog in
Avatar of JosephRalph
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"></SelectedItemStyle>
<HeaderTemplate>
            <TD># Parcelas</TD>
            <TD>Fecha de Envio</TD>
            <TD>Numero Control</TD>
            <TD>Link</TD>                                                
</HeaderTemplate>
<FooterStyle ForeColor="#8C4510" BackColor="#F7DFB5"></FooterStyle>
<ItemStyle ForeColor="#8C4510" BackColor="#FFF7E7"></ItemStyle>
<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"></HeaderStyle>
</asp:datalist>
Avatar of nauman_ahmed
nauman_ahmed
Flag of United States of America image

So what is not working? None of the style attributes work?

-Nauman.
Avatar of JosephRalph
JosephRalph

ASKER

nop, the style is not working
Do you see the control formatting in VS.NET?

-Nauman.
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.
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:#DEBA84;border-color:#DEBA84;border-width:1px;border-style:None;width:424px;">
      <tr>
            <td style="color:White;background-color:#A55129;font-weight:bold;">
                              <TD># Parcelas</TD>
                              <TD>Fecha de Envio</TD>
                              <TD>Numero Control</TD>
                              <TD>Link</TD>
            </td>
      </tr><tr>
            <td style="color:#8C4510;background-color:#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.
the solution I found was

<HeaderTemplate>
<TR style="color:White;background-color:#A55129;font-weight:bold;">
                              <TD># Parcelas</TD>
                              <TD>Fecha de Envio</TD>
                              <TD>Numero Control</TD>
                              <TD>Link</TD>
</TR>
                              </HeaderTemplate>
                        <ItemTemplate>
                        <tr style="color:#8C4510;background-color:#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.

ASKER CERTIFIED SOLUTION
Avatar of DarthMod
DarthMod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial