Demonstrate the use of Datalist link control

 Datalist.aspx 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Datalist.aspx.cs" 

Inherits="_6B.Datalist" %> 

<!DOCTYPE html> 

<html xmlns="http://www.w3.org/1999/xhtml"> 

<head runat="server"> 

    <title></title> 

</head> 

<body> 

    <form id="form1" runat="server"> 

        <div> 

            <asp:DataList ID="DataList1" runat="server" BackColor="White" 

BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" 

DataKeyField="Id" DataSourceID="SqlDataSource1" ForeColor="Black" GridLines="Vertical" Width="349px"> 

                <AlternatingItemStyle BackColor="White" /> 

                <FooterStyle BackColor="#CCCC99" /> 

                <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" /> 

                <ItemStyle BackColor="#F7F7DE" /> 

                <ItemTemplate> 

                    Id: 

                    <asp:Label ID="IdLabel" runat="server" Text='<%# Eval("Id") %>' /> 

                    <br /> 

                    Name: 

                    <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' /> 

                    <br />                     City: 

                    <asp:Label ID="CityLabel" runat="server" Text='<%# Eval("City") %>' /> 

                    <br />                     State: 

                    <asp:Label ID="StateLabel" runat="server" Text='<%# Eval("State") %>' /> 

                    <br /> 

<br /> 

                </ItemTemplate> 

                <SelectedItemStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />             </asp:DataList> 

            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ 

ConnectionStrings:connStr %>" SelectCommand="SELECT * FROM 

[Customer]"></asp:SqlDataSource> 

        </div> 

    </form> 

</body> 

</html> 

Output:-



Post a Comment

0 Comments