Create a web application to demonstrate use of GridView control template and GridView hyperlink

 .aspx file 

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

Inherits="_6A._9a" %> 

<!DOCTYPE html> 

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

<head runat="server"> 

    <title></title> 

</head> 

<body> 

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

        <br />    

            <asp:GridView ID="GridView1" runat="server" Height="241px" Width="274px" 

AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" 

BorderStyle="None" BorderWidth="1px" CellPadding="3" DataKeyNames="Id" 

DataSourceID="SqlDataSource1" GridLines="Vertical"> 

                <AlternatingRowStyle BackColor="#DCDCDC" /> 

                <Columns> 

                    <asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True" 

SortExpression="Id" /> 

                    <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" /> 

                    <asp:BoundField DataField="STD" HeaderText="STD" SortExpression="STD" /> 

                    <asp:BoundField DataField="Address" HeaderText="Address" 

SortExpression="Address" /> 

                    <asp:BoundField DataField="Phone No." HeaderText="Phone No." 

SortExpression="Phone No." /> 

                    <asp:HyperLinkField DataTextField="Id" /> 

                </Columns> 

                <FooterStyle BackColor="#CCCCCC" ForeColor="Black" /> 

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

                <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" /> 

                <RowStyle BackColor="#EEEEEE" ForeColor="Black" /> 

                <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" /> 

                <SortedAscendingCellStyle BackColor="#F1F1F1" /> 

                <SortedAscendingHeaderStyle BackColor="#0000A9" /> 

                <SortedDescendingCellStyle BackColor="#CAC9C9" /> 

                <SortedDescendingHeaderStyle BackColor="#000065" />             

</asp:GridView> 

        <br /> 

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

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

[Student]"></asp:SqlDataSource> 

    </form> 

</body> 

</html> 

Output:- 



Post a Comment

0 Comments