Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
source:
XML
<asp:DataList ID="datalist1" style="  margin-left:5px; text-align:left" runat="server"
        Width="996px" CellPadding="4" ForeColor="#333333" Height="228px">
    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
    <AlternatingItemStyle BackColor="White" ForeColor="#284775" />
    <ItemStyle BackColor="#F7F6F3" ForeColor="#333333" />
    <SelectedItemStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderTemplate>
<asp:Label ID="uname" style="width:150px; font-weight:bold; margin-left:20px;" runat="server" Text="User Name" ></asp:Label>
<asp:Label ID="cname" style="width:150px;font-weight:bold; margin-left:20px;" runat="server" Text="Company Name" ></asp:Label>
<asp:Label ID="contact" style="width:150px;font-weight:bold; margin-left:20px;" runat="server" Text="Conatct Number" ></asp:Label>
<asp:Label ID="Label1" style="width:150px;font-weight:bold; margin-left:40px;" runat="server" Text="Email" ></asp:Label>
<asp:Label ID="Address" style="width:150px;font-weight:bold; margin-left:100px;" runat="server" Text="Address"></asp:Label>
<asp:Label ID="status" style="width:150px;font-weight:bold; margin-left:100px;" runat="server" Text="Status"></asp:Label>
</HeaderTemplate>
    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<ItemTemplate>
<asp:Label ID="uname" style="width:100px;margin-left:30px;" runat="server" Text='<%#Eval("uid") %>' ></asp:Label>
<asp:Label ID="cname" style="width:100px; margin-left:30px;" runat="server" Text='<%#Eval("cname") %>' ></asp:Label>
<asp:Label ID="contact" style="width:100px;margin-left:50px;" runat="server" Text='<%#Eval("Contact") %>' ></asp:Label>
<asp:Label ID="Label2" style="width:100px;margin-left:80px; " runat="server" Text='<%#Eval("email") %>' ></asp:Label>
<asp:Label ID="Address" style="width:100px;margin-left:70px; height:100px;" runat="server" Text='<%#Eval("address") %>'></asp:Label>
<asp:Label ID="status" style="width:150px; margin-left:80px;" runat="server" Text='<%#Eval("status") %>'></asp:Label>
<asp:CheckBox ID="CheckBox1" style="margin-left:10px;" runat="server" />
<asp:LinkButton ID="LinkButton1" style="margin-left:10px;" runat="server" Text="Change status" CommandName="change"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" style="margin-left:10px;" runat="server" Text="Delete" CommandName="del"></asp:LinkButton>


</ItemTemplate>
</asp:DataList>




c sharp file:

C#
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Web.Configuration;
public partial class admin : System.Web.UI.Page
{
    string con = WebConfigurationManager.ConnectionStrings["connection"].ToString();
   
    protected void Page_Load(object sender, EventArgs e)
    {
        bind();
        
    }
    public void bind()
    {
      
        SqlDataAdapter da = new SqlDataAdapter("select *from reg",con); 
        DataSet ds=new DataSet();
        da.Fill(ds);
        datalist1.DataSource = ds;
        datalist1.DataBind();
     
    }

}
Posted
Updated 30-Aug-13 0:43am
v3
Comments
Mahesh Bailwal 30-Aug-13 6:57am    
are you getting any error?
Manikandan Sekar 2-Sep-13 2:51am    
Is the connection is working properly, and make sure that the returned dataset has all the same fields with same alias name for the fields which you bind in the datalist

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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