.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

How to use DataList in asp.net

Posted By: Ramesh     Posted Date: November 02, 2008    Points:2   Category :ASP.Net
How to use DataList in my Asp.Net Application. I want to use DataList.Please help me...

Thanks in Advance

Author: susant             
Posted Date: November 03, 2008     Points: 5   

Hi Ramesh \check this one..

1: take one datalist on ur .aspx page
2: in .cs file write the code to populate data
string str = "select *from student";
SqlDataAdapter da = new SqlDataAdapter(str, con);
DataSet ds = new DataSet();
da.Fill(ds, "temp");
DataList1.DataSource = return_data(str, "temp");

3: In aspx source file:

<asp:DataList ID="DataList1" runat="server">
<td><%# DataBinder.Eval(Container.DataItem,"roll_no") %></td>
<td><%# DataBinder.Eval(Container.DataItem,"s_name") %> </td>
<td><%# DataBinder.Eval(Container.DataItem,"city") %></td>

Note: the code (Container.DataItem,"roll_no") from student table roll_no is the column name


Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend