• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 423
  • Last Modified:

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>
0
JosephRalph
Asked:
JosephRalph
  • 4
  • 2
1 Solution
 
nauman_ahmedCommented:
So what is not working? None of the style attributes work?

-Nauman.
0
 
JosephRalphAuthor Commented:
nop, the style is not working
0
 
nauman_ahmedCommented:
Do you see the control formatting in VS.NET?

-Nauman.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
JosephRalphAuthor Commented:
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.
0
 
JosephRalphAuthor Commented:
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.
0
 
JosephRalphAuthor Commented:
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.

0
 
DarthModCommented:
PAQed with points refunded (75)

DarthMod
Community Support Moderator
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now