Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

ASP.

NET
Chap 1- Introduction to Asp.net
1) What is ASP.Net? Explain the page structure of asp.net.
It is a web framework designed and developed by Microsoft. It is used to
develop websites, web applications and web services. It provides
fantastic integration of HTML, CSS and JavaScript. It was first released in
January 2002. It is built on the Common Language Runtime (CLR) and
allows programmers to write code using any supported .NET language.
ASP.NET provides three development styles for creating web
applications:
1. Web Forms:
It is an event driven development framework. It provides server-side
controls and events to create web application.
2. ASP.NET MVC:
It gives us a MVC (Model View Controller), patterns-based way to build
dynamic websites.
3. ASP.NET Web Pages:
It is used to create dynamic web pages. It provides fast and lightweight
way to combine server code with HTML.
Structure of Asp.Net Page:
An ASP.NET page is made up of a number of server controls along with
HTML controls, text, and images. Sensitive data from the page and the
states of different controls on the page are stored in hidden fields that
form the context of that page request. An ASP.NET page is also a server
side file saved with the .aspx extension. It is modular in nature and can
be divided into the following core sections:
1. Page Directives:
The page directives set up the environment for the page to run. The
@Page directive defines page-specific attributes used by ASP.NET page
parser and compiler.
2. Code Section:
The code section provides the handlers for the page and control events
along with other functions required.
3. Page Layout:
The page layout provides the interface of the page. It contains the server
controls, text, inline JavaScript, and HTML tags.
2) What is single page model? Explain its advantage and disadvantage.
In the single-file page model, a Web Forms page's markup and its
programming code are in the same physical .aspx file. The programming
code is in a script block that contains the attribute runat="server" to mark
it as code that ASP.NET should execute.
Example:
<%@ Page Language="C#" %>
<script runat="server">
void Button1_Click(Object sender, EventArgs e)
{
Label1.Text = "Clicked at " + DateTime.Now.ToString();
}
</script>
<html>
<head>
<title>Single-File Page Model</title>
</head>
<body>
<form runat="server">
<div>
<asp:Label id="Label1" runat="server" Text="Label">
</asp:Label><br />
<asp:Button id="Button1" runat="server" onclick="Button1_Click"
Text="Button">
</asp:Button>
</div>
</form>
</body>
</html>
Advantages:
 In pages where there is not very much code, the convenience of
keeping the code and markup in the same file can outweigh For
example, it can be easier to study a single-file page because you can
see the code and the markup in one place.
 Pages written using the single-file model are slightly easier to deploy
or to send to another programmer because there is only one file.
 Managing files in a source code control system is slightly easier,
because the page is self-contained in a single file.
Disadvantages:
 Each time when there is a request for page it compiles the code each
time then server the page Like classic asp because inline code cannot
create dll.
 we are not able to see the code, only the results are rendered when
the page runs.

3) What is code behind model? Explain its advantage and disadvantage.


The code-behind page model for Web Forms allows you to keep the
markup in one file—the .aspx file—and the programming code in another
file. The name of the code file varies according to what programming
language you are using. For example, if you are working with a page
named SamplePage, the markup is in the file SamplePage.aspx and the
code is in a file named SamplePage.aspx.vb (for Visual Basic) and
SamplePage.aspx.cs (for C#).
Advantages:
1. Code-behind pages offer a clean separation of the markup (user
interface) and code. It is practical to have a designer working on the
markup while a programmer writes code.
2. Code is not exposed to page designers or others who are working only
with the page markup.
3. Code can be reused for multiple pages.

4) State the difference between Single Page Model and Code behind
model.
Single page Model Code Behind Model
The business logic is in The HTML and controls are in
<script> blocks in the same the .aspx file, and the
.aspx file that contains the business logic is in a separate
HTML and controls. .aspx.cs or .aspx.vb file.
When the page is deployed, All project class files (without
the source code is deployed the .aspx file ) are compiled
along with the Web Forms into a .dll file, which are
page, since it is physically in deployed to the server
the .aspx file. Though, we are without any source code.
not able to see the code, only When a request for the page
the results are rendered is received, then an instance
when the page runs. of the project .dll file is
created and executed.
The .aspx file derives from the The code for the page is
Page class. compiled into a separate
class from which the .aspx file
derives.
When we write inline code, The code-behind approach
we write code in the same also improved productivity
page with Html code (at some level) since the
between scripting tags. So, designer and the developer
each time when there is a can continue working
request for page it compiles simultaneously on the same
the code each time then set of application. It's also
server the page Like classic easier to build & test the UI
asp because inline code and the business logic (DLL) -
cannot create dll. separately or combined.

5) Explain Asp.net Page life cycle.


In ASP.NET, a web page has execution lifecycle that includes various
phases. These phases include initialization, instantiation, restoring and
maintaining state etc. it is required to understand the page lifecycle so
that we can put custom code at any stage to perform our business logic.
The lifecycle stages of ASP.NET web page are:
1. Page request:
This stage occurs before the lifecycle begins. When a page is
requested by the user, ASP.NET parses and compiles that page.
2. Start:
In this stage, page properties such as Request and response are set. It
also determines the Request type.
3. Initialization:
In this stage, each control's UniqueID property is set. Master page is
applied to the page.
4. Load:
During this phase, if page request is postback, control properties are
loaded with information.
5. Postback event handling:
In this stage, event handler is called if page request is postback. After
that, the Validate method of all validator controls is called.
6. Rendering:
Before rendering, view state is saved for the page and all controls.
During the rendering stage, the page calls the Render method for each
control, providing a text writer that writes its output to the
OutputStream object of the page's Response property.
7. Unload:
At this stage the requested page has been fully rendered and is ready
to terminate.at this stage all properties are unloaded and cleanup is
performed.

Chap 2- Asp.net controls


1) Explain any two server controls with example.
1.Label Control:
 This control is used to display textual information on the web forms.
 It is mainly used to create caption for the other controls like: textbox.
 To create label either we can write code or use the drag and drop
facility of visual studio.
 This is server side control, asp provides own tag to create label. The
example is given below.
< asp:LabelID="Label1" runat="server" Text="Label" ></asp:Label>
2.Button Control:
 This control is used to perform events. It is also used to submit client
request to the server. To create Button either we can write code or
use the drag and drop facility of visual studio IDE.
 This is a server side control and asp provides own tag to create it. The
example is given below.
< asp:ButtonID="Button1" runat="server" Text="Submit"
BorderStyle="Solid" ToolTip="Submit"> </asp:Button>
 Server renders it as the HTML control and produces the following
code to the browser.
<input name="Button1" value="Submit" id="Button1" title="Submit"
style="borderstyle:Solid;" type="submit">

2) Explain any two HTML controls.


HTMLInputButton Control:
 The HTML elements allow user to create submit button, reset button
and command button. The server side maps to the <input
type=button> and <input type=reset>.
 The general syntax for the InputButton control is:
<input type=button | submit | reset id="btn1"
OnServerClick="onserverclickhandler" runat="server">
 When the user clicks the HTML InputButton, input from the control is
processed. The response is sent back to the client.
HTMLAnchor Control:
 The HTML Anchor is similar to the <a> tag. It creates an hyperlink
useful for navigating from one page to another.
 The general syntax for the HTMLAnchor control is:
<a id="Anchor1" runat="server" name="User1"
OnServerClick="onserverClickHandler" title="Value to be shown"
target="linktosite" href="linkurl" > Welcome </a>
where,
id is the unique identifier assigned to the control,
name is the reference for the client side,
target is the frame or window on which the page is specified,
title is the tooltip value for the attribute,
href is the URL of the page on which it is linked.
3) Write a short note on FileUpload Control.
 It is an input controller which is used to upload file to the server.
 It creates a browse button on the form that pop up a window to select
the file from the local machine.
 To implement FileUpload we can drag it from the toolbox in visual
studio.
 This is a server-side control and ASP.NET provides own tag to create
it. The example is given below-
< asp:FileUpload ID="FileUpload1" runat="server"/>
 Server renders it as the HTML control and produces the following code
to the browser.
<input name="FileUpload1" id="FileUpload1" type="file">
4) Explain AdRotator Control with example.
 The AdRotator control selects from the banner advertisements. They
are added in an XML file.
 The file is known as advertisement file. The control states the file and
the window used for linking the file.
 Syntax:
< asp: AdRotator AdvertisementFile="file1.xml" runat="server"
Target="_top” />
 The advertisement file consist information about the advertisements
to be displayed.The data is saved in a structured format through the
formatted tags.
 The elements used in the advertisement file are mentioned below.
1. Ad: A unique Ad element is added to the file
2. Advertisements: The advertisement file is present in this tag
3. NavigateUrl: The link user follows when the ad is clicked
 Properties of the AdRotator control are:
1. DataSource: The control where the data is accessed
2. AlternateTextField: The field name where the alternate text is
provided
3. Font: The font associated with the banner control is defined
5) Explain MultiView Control with example.
 MultiView and View controls allow you to divide the content of a page
into different groups, displaying only one group at a time.
 Each View control manages one group of content and all the View
controls are held together in a MultiView control.
 The MultiView control is responsible for displaying one View control
at a time. The View displayed is called the active view.
 Syntax for MultiView control:
<asp:MultiView ID="MultView1" runat="server">
<asp:View ID="view1" runat="server"></asp:View>
</asp:MultiView>
 Properties of multiview control:
1. ID: The unique identifier used for identifying the control on the web
page
2. Views: The group of view controls in a multiview control
3. ActiveViewIndex: It is zero based index used for representing the
active view.
 Methods of multiview control:
1. GetActiveView: The active view is accessed by the user
2. SetActiveView: The active view is assigned by the user

6) Explain Panel Control with example.


 The panel control acts storage for all the controls used in the page.
 The appearance for the controls is managed.
 Syntax for Panel control:
<asp:Panel ID="Panel1" runat="server">
<asp:Panel>
 Properties of Panel control:
1. Direction: The text direction of the control in the panel is defined
2. BackImageUrl: The background image of the post is stated
3. GroupingText: The grouping of the text as a field is defined
4. Wrap: The text wrapping is performed
5. ScrollBars: The scrollbars are assigned within the panel

7) Explain CompareValidator with example.


 CompareValidator is used to compare the value of an input
control against a value of another input control.
 We can use comparison operators like: less than, equal to,
greater than etc.
 Properties:
BackColor: It is used to set background color of the control.
Font: It is used to set font for the control text.
Text: It is used to set text to be shown for the control
 Example
<form id="form1" runat="server">
<table class="auto-style1">
<tr>
<td>
<asp:TextBox ID="firstval" runat="server"
required="true"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="secondval"
runat="server"></asp:TextBox> It should be greater than
first value</td>
</tr>
</table>
<asp:Button ID="Button1" runat="server" Text="save"/>
< asp:CompareValidator ID="CompareValidator1"
runat="server" ControlToCompare="secon
dval" ControlToValidate="firstval" Display="Dynamic"
ErrorMessage="Enter valid value" ForeColor="Red"
Operator="LessThan"
Type="Integer"></asp:CompareValidator>
</form>
8) Explain RangeValidator with example.
 RangeValidator evaluates the value of an input control to
check the specified range.
 It allows us to check whether the user input is between a
specified upper and lower boundary. This range can be
numbers, alphabetic characters and dates.
 Properties:
BackColor: It is used to set background color of the control.
Font: It is used to set font for the control text.
Text: It is used to set text to be shown for the control
 Example:
<form id=”form1” runat=”server”>
<table>
<tr>
<td class="auto-style3">
<asp:Label ID="Label2" runat="server" Text="Enter a
value"></asp:Label>
</td>
<td>
<asp:TextBox
ID="uesrInput"runat="server"></asp:TextBox>
<asp:RangeValidator ID="RangeValidator1" runat="server"
ControlToValidate="uesrInput" ErrorMessage="Enter value
in specified range" ForeColor="Red" MaximumValue="199"
MinimumValue="101" SetFocusOnError="True"Type="
Integer"></asp:RangeValidator>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button2" runat="server" Text="Save"/>
</td>
</tr>
</table>
</form>
Chap 3- ASP.Net Intrinsic Objects and State Management
1) Write a short note on http request
object(properties,method)
 The HttpRequest object represents the incoming request from the client to the Web
server.
 The request from the client can come in two ways GET or POST.
 GET attaches the data with the URL, whereas POST embeds the data within the HTTP
request body.
 The HttpRequest intrinsic object can be accessed by the Request property of the Page
class.
Properties of the HttpRequest class:
1. Browser: Provides access to the capabilities and characteristics of the requesting
browser
2. FilePath: Specifies the virtual path of the file on the Web server
3. Form: Specifies the contents of a form posted to the server
4. UserAgent: Represents the browser being used by the client
Methods of the HttpRequest class:
1. BinaryRead() : Reads the specified number of bytes from the request stream.
2. MapPath() : Returns the physical file system path of the file
for a specified virtual path of a Web server.
3. SaveAs() : Saves the current HTTP request into a disk file, with an option to include
or exclude headers.
2) Write a short note on http Responce object.
 The Response object represents the server's response to the client request. It is an
instance of the System.Web.HttpResponse class.
 In ASP.NET, the response object does not play any vital role in sending HTML text to the
client, because the server-side controls have nested, object oriented methods for
rendering themselves.
 the HttpResponse object still provides some important functionalities, like the cookie
feature and the Redirect() method.
 The Response.Redirect() method allows transferring the user to another page, inside as
well as outside the application. It requires a round trip.
Properties of the Response Object:
1. Charset: Gets or sets the HTTP character set of the output stream.
2. Cookies: Gets the response cookie collection.
3. Headers: Gets the collection of response headers.
Methods of Response object:
1. SetCookie : Updates an existing cookie in the cookie collection.
2. Write(Object) : Writes an object to an HTTP response stream.
3. GetType : Gets the Type of the current instance.
3) Write a short note on http server utility.
 The HttpServerUtility object contains utility methods and properties to work with the
Web server.
 It also contains methods to enable HTML/URL encoding and decoding, execute or
transfer to an ASPX page, create COM components , and so on.
 The Server property of the Page class provides access to the HttpServerUtility object.

Properties:
1. MachineName: Returns the name of the server that hosts the Web application
2. ScriptTimeout: Indicates the number of seconds that are allowed to elapse when
processing the request before a timeout error is sent to the client
Methods:
1. ClearError() : Clears the last exception from memory
2. CreateObject() : Creates a COM object on the server
3. Execute() : Executes an ASPX page within the current requested page
4. GetLastError() : Returns the last exception that occurred on the Web server
4) Write a short note on http application state.
 The ASP.NET application is the collection of all web pages, code and other files within a
single virtual directory on a web server.
 When information is stored in application state, it is available to all the users. To provide
for the use of application state, ASP.NET creates an application state object for each
application from the HTTPApplicationState class and stores this object in server
memory.
 This object is represented by class file global.asax.
 Application State is mostly used to store hit counters and other statistical data.

Properties:
1. Itemname: - The value of the application state item with the specified name.
2. Count:- This is the default property of the HttpApplicationState class. The number
of items in the application state collection.
Methods:
1. Clear: Removes all the items from the application state collection.
2. Removename: Removes the specified item from the application state collection.
3. RemoveAll: Removes all objects from an HttpApplicationState collection.
5) Write a short note on http session state.
 When a user connects to an ASP.NET website, a new session object is created. When
session state is turned on, a new session state object is created for each new request.
 This session state object becomes part of the context and it is available through the
page.
 Session state is generally used for storing application data such as inventory, supplier
list, customer record, or shopping cart. It can also keep information about the user and
his preferences, and keep the track of pending operations.
Properties:
1. SessionID: The unique session identifier
2. Itemname: The value of the session state item with the specified name.
3. Count: The number of items in the session state collection.
Methods:
1. Clear: Removes all the items from session state collection.
2. Removename: Removes the specified item from the session state collection.
3. RemoveAll: Removes all keys and values from the session-state collection.
6) Write a short note on view state.
 ViewState is a important client side state management technique. ViewState is used to
store user data on page at the time of post back of web page.
 ViewState does not hold the controls, it holds the values of controls. It does not restore
the value to control after page post back.
 ViewState can hold the value on single web page, if we go to other page using
response.redirect then ViewState will be null.
 ViewState stores data on single page. ViewState is client side state management
technique
 Example:
//Store the value in viewstate
ViewState[“name”]=”Eagle Computers”;
//Retrieve information from viewstate
string value=ViewState[“name”].ToString();

7) What is cookies ? explain types of cookies.


 Cookies is a small pieces of text information which is stored on user hard drive using
users browser for identify users.
 It may contain username, ID, password or any information. Cookie does not use server
memory.
 Cookies stored user computer at “C”\Document and Setting\Current
login_User\Cookie”.
 Types of Cookies:
1. Persistence Cookie: This type of cookies is permanently stored on user hard drive.
Cookies which have an expiry date time are called persistence cookies. These types
of cookies stored user hard drive permanently till the date time we set.
Example:
Response.Cookies[“name”].Value = “Eagle Computers”;
Response.Cookies[“Eagle”].Expires = DateTime.Now.AddMinutes(10);
2. Non-Persistence Cookie: This types of cookies are not permanently stored on user
hard drive. It stores the information up the user accesng the same browser. When
user closes the browser the cookies will be automatically deleted.
Example:
Response.Cookies[“name”].Value = “Eagle Computers”;

8) What is session? How to create ? How to retrieve session ?


9) Session is a period of time to visit a website for a particular user. Session can
store the client data on a server
10) Session is a best state management features to store the client data on server
separately for each user.
11) Session can store value across on multiple pages of website
12) By default, Session state is enabled for all ASP.NET applications
13) When you login to any website with username and password. your username
shows on all other pages.The username will be stored in session and on page we access
session value to display username.
14) Declare session in asp.net:
Session[“name”]=”Eagle Computers”;
Response.Redirect(“nextpage.aspx”);
15) Retrieve session value on other page:
string myvalue= Session[“name”].ToString();
Response.Write(“Name = ” + myvalue);

Chap 4- Web Site Designing


1) Explain the different types of principles of website designing?
1. Purpose
Each page of your website needs to have a clear purpose, and to fulfill a
specific need for your website users in the most effective way possible.
2. Communication
Make your information easy to read and digest. Some effective tactics to
include in your web design include: organising information using
headlines and sub headlines, using bullet points instead of long windy
sentences, and cutting the waffle.
3. Typefaces
The ideal font size for reading easily online is 16px and stick to a
maximum of 3 typefaces in a maximum of 3 point sizes to keep your
design streamlined.
4. Colours
Using contrasting colours for the text and background will make reading
easier on the eye. Vibrant colours create emotion and should be used
sparingly (e.g. for buttons and call to actions).
5. Images
A picture can speak a thousand words, and choosing the right images,
infographics, videos and graphics for your website can help with brand
positioning and connecting with your target audience.
6. Navigation
Navigation is about how easy it is for people to take action and move
around your website. Following the ‘three click rule’ which means users
will be able to find the information they are looking for within three
clicks.
7. Grid based layouts
Grid based layouts arrange content into sections, columns and boxes that
line up and feel balanced, which leads to a better looking website design.
8. “F” Pattern design
Most of what people see is in the top and left of the screen and the right
side of the screen is rarely seen. Effectively designed websites will work
with a reader’s natural behavior and display information in order of
importance (left to right, and top to bottom).
9. Load time
To make page load times more effective include optimizing image sizes,
combining code into a central CSS or JavaScript file and minify HTML, CSS,
JavaScript.
10: Mobile friendly
If your website is not mobile friendly, you can either rebuild it in a
responsive layout (this means your website will adjust to different screen
widths) or you can build a dedicated mobile site (a separate website
optimized specifically for mobile users) it is easy to create a beautiful and
functional website, simply by keeping these design elements in mind.

2) What is Master Page ? Explain the advantages of Master Page.


 Master Pages are used when user needs a consistent look and
behavior over all web pages in an application.
 When a user needs to attach header and footer for all the web pages
in an application, the master pages are used.
 Master pages provide a template for all other pages in an application.
The master pages define placeholders for the content, which are
overridden for the content.
 The result is combination of master and content page. Every master
page has one or more content pages in an application.
 Advantages:
1. They provide an object model allowing users to customize the
master page from the individual content pages.
2. They allows user design the rendering of the controls in the
placeholder
3. It is centralized with common functionality of all pages to makes
updates in one place
4. Code can be applied on one set of controls and the results to the
set of pages in the application
3) Write a short note on Site Map.
 A site map is a graph representing all the pages and directories in a web
site.
 Site map information shows the logical coordinates of the page and
allows dynamic access of the pages and render all navigational
information in a graphical way.
 The output of a SiteMapDataSource can be bound to hierarchical data-
bound controls such as Menu or TreeView.
 The SiteMapPath control basically is used to access web pages of the
website from one webpage to another.
 It is a navigation control and displays the map of the site related to its
web pages. This map includes the pages in the particular website and
displays the name of those pages. You can click on that particular page
in the Site Map to navigate to that page.
 The representation of the SiteMapPath control is as follows:
Root Node->Child Node
4) Write a short note on TreeView Control.
 The TreeView control is used for logically displaying the data in a
hierarchical structure.
 We can use this navigation control for displaying the files and folders
on the webpage.
 We can easily display the XML document,Web.SiteMap files and
Database records in a tree structure.
 There are some types to generate navigation on webpage through
TreeView control.
1. TreeView Node Editor dialog box
2. Generate TreeView based on XML Data
3. Generate TreeView based on Web.SiteMap data
4. Generate TreeView from Database
5) Write a short note on Menu Control.
 The menu control is a Navigation control, which is used to display the
site navigation information.
 This can be used to display the site data structure vertically and
horizontally.
 It can be used a binding control as TreeView control. Means we can
easily bind the XML and SiteMap data in menu control.
 The menu control can be used as two types.
1. Static menu:- It is used to display the parent menu items and their sub
menu items on the page.Means it is used to display the entire structure
of the static menu.
2. Dynamic menu:- It is used to display the static menu as well as dynamic
menu on the site.it Means when user passes the mouse over the menu
then it will appear on the site.

6) Write a short note on Site Map Path Control


 The SiteMapPath control is also used to display the Navigation
information on the site.
 It display the current page's context within the entire structure of a
website.
 There are some steps to implement the SiteMapPath control on the web
page.Which are given below:
Step 1: First open visual studio, create project, add web form, add site.
Step 2:Now drag and drop SiteMapPath control on the web Form. Now
drag and drop HyperLink control on the Form.
Step 3: Now Add three more Web Form.
Step 4: Now Go page1.aspx -->drag and drop SiteMapPath control and
HyperLink control on the Form-->Set the NavigateUrl of each HyperLink
control.
Step 5: Now Go page2.aspx -->Same steps perform as step 4.
Step 6: Now Go page3.aspx -->Same steps perform as step 4 and step 5.
Step 7: Now Run the program(press F5)
Chap 5- Data Access With ADO.Net Object
1) Write a short note on dataset.
 DataSet provides a disconnected representation of result sets from the
Data Source, and it is completely independent from the Data Source.
 DataSet provides much greater flexibility when dealing with related
Result Sets.
 DataSet contains rows, columns,primary keys, constraints, and relations
with other DataTable objects.
 It consists of a collection of DataTable objects that you can relate to each
other with DataRelation objects.
 The DataAdapter Object provides a bridge between the DataSet and the
Data Source.

2) Write a short note on dataprovider.


 The .Net Framework includes mainly three Data Providers for ADO.NET.
They are the Microsoft SQL Server Data Provider, OLEDB Data Provider
and ODBC Data Provider.
 SQL Server uses the SqlConnection object , OLEDB uses the
OleDbConnection Object and ODBC uses OdbcConnection Object
respectively.
 A data provider contains Connection, Command, DataAdapter, and
DataReader objects. These four objects provides the functionality of Data
Providers in the ADO.NET.
 The Connection Object provides physical connection to the Data Source.
 The DataReader Object is a stream-based , forward-only, read-only
retrieval of query results from the Data Source.
 DataAdapter Object populate a Dataset Object with results from a Data
Source
3) Write a short note on Repeater control.
 The ASP.NET Repeater is a basic container control that allows you to
create custom lists from any data available to the page.
 It provides a highly customized interface. It renders a read-only template;
in other words, it supports only the ItemTemplate to define custom
binding.
 The Repeater control is a Data Bind Control, also known as container
controls.
 The Repeater control is used to display a repeated list of items that are
bound to the control.
 It has no built-in layout or styles, so you must explicitly declare all layout,
formatting and style tags within the controls templates.
 The Repeater control supports the following features:
 List format
 No default output
 More control and complexity
 Item as row
 no built-in selection capabilities
 no built-in support for edit, insert and delete capabilities
4) Write a short note on datalist.
 DataList allows you to repeat columns horizontally or vertically. The
DataList control renders data as a table and enables you to display data
records in various layouts, such as ordering them in columns or rows.
 You can configure the DataList control to enable users to edit or delete a
record in the table. We can use a DataList control where we need a single-
column list.
 The DataList control works like the Repeater control, used to display the data in a
repeating structure, such as a table. It displays data in a format that you can define
using a template and styles.
 The DataList control does not automatically use a data source control to
edit data. Instead, it provides command events in which you can write
your own code for these scenarios.
 The DataList control supports the following features:
 Support for binding data source controls such as SqlDataSource,
LinqDataSource and ObjectDataSource
 Directional rendering
 Good for columns
 Item as cell
 Updatable
 Control over Alternate item
5) Write a short note on GridView.
 ASP.NET provides a number of tools for showing tabular data in a grid,
including the GridView control.
 The GridView control is used to display the values of a data source in a
table. Each column represents a field where each row represents a record.
It can also display empty data.
 The GridView control provides many built-in capabilities that allow the
user to sort, update, delete, select and page through items in the control.
 The GridView control offers improvements such as the ability to define
multiple primary key fields, improved user interface customization using
bound fields and templates and a new model for handling or canceling
events.
 The GridView control supports the following features:
 Improved data source binding capabilities
 Tabular rendering – displays data as a table
 Item as row
 Built-in sorting capability
 Built-in select, edit and delete capabilities
 Built-in paging capability
 Built-in row selection capability
 Multiple key fields
 Slow performance as compared to Repeater and DataList control

You might also like