Click here to Skip to main content
15,921,577 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
how to bind data from sql server to datalist using asp.net and C#
Posted
Comments
Saral S Stalin 2-Apr-12 3:40am    
Try googling for solutions first, before posting questions.

Try it[^]

Regards
 
Share this answer
 
hI ,
HTML
<div>
    <asp:DataList ID="DataList1" runat="server">
                 <ItemTemplate >
                 <tr>
                 <td>
                    <asp:Label ID="Label1" runat="server"
                         Text="<%# Bind('item_code') %>"></asp:Label>
                        </td>
                        <td>
                             <asp:Label ID="Label2" runat="server"
                         Text="<%# Bind('Item_name') %>"></asp:Label>
                               </td>
                               <td>
                         <asp:Label ID="Label3" runat="server"
                         Text="<%# Bind('brand') %>"></asp:Label></td>
                        </tr>
                        </ItemTemplate>

             </asp:DataList>
        <br />
        <br />
    </div>

Code behind :
C#
DataClassesDataContext db = new DataClassesDataContext();
   protected void Page_Load(object sender, EventArgs e)
   {
       var resultItems = from x in db.Items
                         select x;
       DataList1.DataSource = resultItems;
       DataList1.DataBind();


   }
 
Share this answer
 
Comments
Member 10530354 1-Mar-15 4:53am    
I am making a photo gallery in which I am first uploading the images and then making thumbnails and now i want to bind thumbnails to a datalist. How can I do that?
Tell both c# and aspx coding

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