in .aspx Page
<asp:DataList ID="DataList1" runat="server" BackColor="White"
BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" CellPadding="4"
GridLines="Horizontal" Width="277px">
<FooterStyle BackColor="White" ForeColor="#333333" />
<HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" />
<ItemStyle BackColor="White" ForeColor="#333333" />
<ItemTemplate>
Id is : <asp:Label ID="Label1" runat="server" Text='<%# bind("id") %>'></asp:Label>
<br />
UserName is : <asp:Label ID="Label2" runat="server" Text='<%# bind("username") %>'></asp:Label>
<br />
Password is : <asp:Label ID="Label3" runat="server" Text='<%# bind("password") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
Id is : <asp:Label ID="Label1" runat="server" Text='<%# bind("id") %>'></asp:Label>
<br />
UserName is :
<asp:TextBox ID="TextBox1" runat="server" Text='<%# bind("username") %>'></asp:TextBox>
<br />
Password is :
</ItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# bind("password") %>'></asp:TextBox>
</EditItemTemplate>
<SelectedItemStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
</asp:DataList>
in .aspx.cs Page
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class Default2 : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("Data Source=TOPS17;Initial Catalog=TestGridview;Integrated Security=True");
protected void Page_Load(object sender, EventArgs e)
{
fill_datalist();
}
public void fill_datalist()
{
SqlDataAdapter da = new SqlDataAdapter("select * from tbl_reg",con);
DataSet ds = new DataSet();
da.Fill(ds);
DataList1.DataSource = ds;
DataList1.DataBind();
}
}
<asp:DataList ID="DataList1" runat="server" BackColor="White"
BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" CellPadding="4"
GridLines="Horizontal" Width="277px">
<FooterStyle BackColor="White" ForeColor="#333333" />
<HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" />
<ItemStyle BackColor="White" ForeColor="#333333" />
<ItemTemplate>
Id is : <asp:Label ID="Label1" runat="server" Text='<%# bind("id") %>'></asp:Label>
<br />
UserName is : <asp:Label ID="Label2" runat="server" Text='<%# bind("username") %>'></asp:Label>
<br />
Password is : <asp:Label ID="Label3" runat="server" Text='<%# bind("password") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
Id is : <asp:Label ID="Label1" runat="server" Text='<%# bind("id") %>'></asp:Label>
<br />
UserName is :
<asp:TextBox ID="TextBox1" runat="server" Text='<%# bind("username") %>'></asp:TextBox>
<br />
Password is :
</ItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# bind("password") %>'></asp:TextBox>
</EditItemTemplate>
<SelectedItemStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
</asp:DataList>
in .aspx.cs Page
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class Default2 : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("Data Source=TOPS17;Initial Catalog=TestGridview;Integrated Security=True");
protected void Page_Load(object sender, EventArgs e)
{
fill_datalist();
}
public void fill_datalist()
{
SqlDataAdapter da = new SqlDataAdapter("select * from tbl_reg",con);
DataSet ds = new DataSet();
da.Fill(ds);
DataList1.DataSource = ds;
DataList1.DataBind();
}
}
No comments:
Post a Comment