datalist.aspx:
<asp:DataList ID="DataList1" runat="server">
<HeaderTemplate><h1>Data List Control.</h1></HeaderTemplate>
<SeparatorTemplate><br /><hr /><br /></SeparatorTemplate>
<ItemTemplate>
<h2> Page ID : <asp:Label ID="lblpn" runat="server" Text='<%# Eval("AutoID") %>'></asp:Label></h2>
Page Name: <asp:Label ID="Label1" runat="server" Text='<%# Eval("PageName") %>'></asp:Label> <br / />
Page Description :<asp:Label ID="Label2" runat="server" Text='<%# Eval("PageDescription") %>'></asp:Label>
Page Active : <asp:Label ID="Label3" runat="server" Text='<%# Eval("Active") %>'></asp:Label>
</ItemTemplate>
</asp:DataList>
datalist.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
public partial class About : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack) { MFIll_DetailViews();}
}
private void MFIll_DetailViews()
{
string strConn = @"Data Source=.\sqlexpress;Initial Catalog=Test;Integrated Security=True";
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlCommand cmd = new SqlCommand("select * from mySampleTable", conn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
DataList1.DataSource = ds.Tables[0];
DataList1.DataBind();
}
}
<asp:DataList ID="DataList1" runat="server">
<HeaderTemplate><h1>Data List Control.</h1></HeaderTemplate>
<SeparatorTemplate><br /><hr /><br /></SeparatorTemplate>
<ItemTemplate>
<h2> Page ID : <asp:Label ID="lblpn" runat="server" Text='<%# Eval("AutoID") %>'></asp:Label></h2>
Page Name: <asp:Label ID="Label1" runat="server" Text='<%# Eval("PageName") %>'></asp:Label> <br / />
Page Description :<asp:Label ID="Label2" runat="server" Text='<%# Eval("PageDescription") %>'></asp:Label>
Page Active : <asp:Label ID="Label3" runat="server" Text='<%# Eval("Active") %>'></asp:Label>
</ItemTemplate>
</asp:DataList>
datalist.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
public partial class About : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack) { MFIll_DetailViews();}
}
private void MFIll_DetailViews()
{
string strConn = @"Data Source=.\sqlexpress;Initial Catalog=Test;Integrated Security=True";
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlCommand cmd = new SqlCommand("select * from mySampleTable", conn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
DataList1.DataSource = ds.Tables[0];
DataList1.DataBind();
}
}
No comments:
Post a Comment