Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

I have a little problem with datalist.
I have a datalist that display data from sql server.
datalist display records from top to down direction.
but i want datalist display records from left to right(only in one row).(Example 1,2,3,4,5,6,7,8,9.........................n nubmer)

i am using this code..

XML
<asp:DataList ID="DataList1" runat="server" CellPadding="4" RepeatLayout="Flow" DataSourceID="SqlDataSource1"
                           ForeColor="#333333" Width="300px" RepeatColumns="2" RepeatDirection="Horizontal">
                           <AlternatingItemStyle BackColor="White" ForeColor="#284775" />
                           <FooterStyle Font-Bold="True" ForeColor="White" BackColor="#5D7B9D" />
                           <HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#5D7B9D" />
                           <ItemStyle ForeColor="#333333" BackColor="#F7F6F3" />
                           <ItemTemplate>
                               <a class='iframe' href="business-plans.aspx?nm='<%# Eval("Name") %>'">
                                   <div class="card" style="min-height: 50px;">
                                       <div class="fl">
                                           <asp:Image ID="Image2" runat="server" Style="border: 1px solid #C6C6C6; float: left;
                                               height: 50px; border-radius: 3px; width: 50px;" ImageUrl='<%# "AdminGetImage.aspx?id=" + Eval("id")%>' />
                                       </div>
                                       <div class="fl" style="margin-left: 7px; width: 215px;">
                                           <div>
                                               <asp:Label ID="Sent_FromLabel" Font-Size="10px" Style="text-transform: capitalize;
                                                   font-weight: bold;" Font-Names="Verdana" ForeColor="#014265" runat="server" Text='<%# Eval("Name") %>' />
                                           </div>
                                           <div>
                                               <div>
                                                   <asp:Label ID="label3" runat="server" Font-Names="Verdana" ForeColor="#014265" Font-Size="10px"
                                                       Text='<%# Eval("Address") %>' />
                                               </div>
                                               <div style="margin-top: 2px;">
                                                   <asp:Label ID="Label1" Font-Size="10px" Font-Names="Verdana" ForeColor="#014265"
                                                       runat="server" Text='<%# Eval("Mobile") %>' />,
                                                   <asp:Label ID="Label4" Font-Size="10px" Font-Names="Verdana" ForeColor="#014265"
                                                       runat="server" Text='<%# Eval("Office") %>' />
                                               </div>
                                               <div>
                                                   <asp:Label ID="Label2" runat="server" Text='<%# Eval("claim_status") %>' class="claim"></asp:Label>
                                               </div>
                                           </div>
                                       </div>
                                       <div class="clr">
                                       </div>
                                   </div>
                               </a>
                           </ItemTemplate>
                           <SelectedItemStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                       </asp:DataList>




XML
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MyArea %>"
               SelectCommand="src_tbl" SelectCommandType="StoredProcedure">
           </asp:SqlDataSource>
Posted
Comments
vijay__p 25-Apr-13 7:04am    
Dont use DataList Use Repeater control
BALBINDER4u 26-Apr-13 4:15am    
Why ?
Please tell me the reason .
ChienVH 4-May-13 14:55pm    
You can use both of DataList and Repeater to do that.
So, after looking at your code, it seems work fine. However, pls try to remove some code and use below code for your testing.

<asp:DataList ID="DataList1" runat="server" RepeatDirection="Horizontal">
<itemtemplate>
//Code here
</itemtemplate>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900