DetailsView Example in ASP.NET using C#

DetailsView Example in ASP.NET using C#

Posted in : ASP.Net Posted on : December 3, 2010 at 6:29 PM Comments : [ 0 ]

In this article we will introduce with DetailsView control in ASP.NET using C#.

DetailsView Example in ASP.NET using C#

DetailsView control in ASP.NET is used to display single record at a time. You can insert, edit, delete and paging the record in DetailsView. In this example we use SQLDataSource for providing data. You can AutoFormat the DetailsView. You can see the following image for AutoFormat.

You will click on special tag button and checks true enable paging. You can see the following figure.

DetailsView.aspx (Design Page):

DetailsView.aspx (source code):

<%@ Page Title="" Language="C#" MasterPageFile="~/RoseindiaMaster.master" 
CodeFile="DetailsView.aspx.cs" Inherits="DetailsView" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<h2 style="color: Green">
DetailsView in ASP.NET 4, C#</h2>
<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="326px" 
AutoGenerateRows="False" CellPadding="4" DataSourceID="SqlDataSource1" 
Font-Names="Verdana" Font-Size="Small" ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
<EditRowStyle BackColor="#999999" />
<FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:BoundField DataField="DOB" HeaderText="DOB" SortExpression="DOB" />
<asp:BoundField DataField="Age" HeaderText="Age" SortExpression="Age" />
<asp:BoundField DataField="Course" HeaderText="Course" SortExpression="Course" />
<asp:BoundField DataField="Branch" HeaderText="Branch" SortExpression="Branch" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:BoundField DataField="MobileNo" HeaderText="MobileNo" SortExpression="MobileNo" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
Student Information
<PagerStyle BackColor="#284775" Font-Names="Verdana" Font-Size="Small"
ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
ConnectionString="<%$ ConnectionStrings:ChartDatabaseConnectionString %>" 
SelectCommand="SELECT * FROM [Student]"></asp:SqlDataSource>


Download source code
Go to Topic «PreviousHomeNext»

Your Comment:

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image

Tutorial Topics