You are on page 1of 6

Q. =Data source control and properties.

Ans.= ASP.NET includes data source controls that allow you to work with differen
t types of data sources such as a database,
an XML file, or a middle-tier business object. Data source controls connect to a
nd retrieve data from a data source and make
it available for other controls to bind to, without requiring code. They can als
o support modifying data.
A data source control, which is derived from the System.Web.UI.DataSourceControl
class, provides a single object that
you can define declaratively (in your web page) or programmatically (in your cod
e-behind file). It will manage internally
the connection to the data, its selection, and various options concerning its pr
esentation (such as paging and caching) so that
all you need to do is tell a UI control what data source to use and everything e
lse is taken care of. In some cases, the controls
also allow you to send changes to that data back to the source from which it ca
me. The entire life cycle of the query to and response
from the data source is encapsulated in this one control.
Many data source controls exist for accessing data from SQL Server, from ODBC or
OLE DB servers, from XML files, and from business objects.
They are divided into two groups: those representing sources of hierarchical dat
a (XML and Sitemap documents) and those representing flat
or table-based data (in business objects, databases, or through LINQ sources), w
ith members of both groups binding to UI objects
(such as DataList and GridView) in the same way and handling the plumbing for yo
u. This is in marked contract to ASP.NET 1.1 development,
where you had to work with the plumbing directly using the ADO.NET object model.
Properties=
Data source controls
SqlDataSource
hat returns SQL data,

Description
It represents a connection to an ADO.NET data provider t

including data sources accessible via OLEDB and QDBC.


ObjectDataSource
It allows binding to a custom .Net business object that
returns data.
LinqdataSource
It allows binding to the results of a Linq-to-SQL query
(supported by ASP.NET 3.5 only).
AccessDataSource
It represents connection to a Microsoft Access database.
Q. =Data bond control.
Ans.=Every ASP.NET web form control inherits the DataBind method from its parent
Control class, which gives it an inherent capability to
bind data to at least one of its properties. This is known as simple data bindin
g or inline data binding.
Simple data binding involves attaching any collection (item collection) which im
plements the IEnumerable interface,
or the DataSet and DataTable classes to the DataSource property of the control.
On the other hand, some controls can bind records, lists, or columns of data int
o their structure through a DataSource control.
These controls derive from the BaseDataBoundControl class. This is called declar
ative data binding.
The data source controls help the data-bound controls implement functionalities
such as, sorting, paging,
and editing data collections.
The BaseDataBoundControl is an abstract class, which is inherited by two more ab
stract classes:

DataBoundControl
HierarchicalDataBoundControl
The abstract class DataBoundControl is again inherited by two more abstract clas
ses:
ListControl
CompositeDataBoundControl
The controls capable of simple data binding are derived from the ListControl abs
tract class and these controls are:
BulletedList
CheckBoxList
DropDownList
ListBox
RadioButtonList
The controls capable of declarative data binding (a more complex data binding) a
re derived from the abstract class CompositeDataBoundControl.
These controls are:
DetailsView
FormView
GridView
RecordList
Q. Write five basic asp.net control?(basic control and basic event)
Ans.
the basic five controls available in ASP.NET.
1. Button Controls
ASP.NET provides three types of button control:
Button : It displays text within a rectangular area.
Link Button : It displays text that looks like a hyperlink.
Image Button : It displays an image.
When a user clicks a button, two events are raised: Click and Command.
2. Text Boxes and Labels
Text box controls are typically used to accept input from the user. A text box c
ontrol can accept one or more lines of
text depending upon the settings of the TextMode attribute.
Label controls provide an easy way to display text which can be changed from one
execution of a page to the next.
If you want to display text that does not change, you use the literal text.
3. Check Boxes and Radio Buttons
A check box displays a single option that the user can either check or uncheck a
nd radio buttons present a group of options
from which the user can select just one option.
To create a group of radio buttons, you specify the same name for the GroupName
attribute of each radio button in the group.
If more than one group is required in a single form, then specify a different g
roup name for each group.
If you want check box or radio button to be selected when the form is initially

displayed, set its Checked attribute to true.


If the Checked attribute is set to true for multiple radio buttons in a group, t
hen only the last one is considered as true.
4. List Controls
ASP.NET provides the following controls
Drop-down list,
List box,
Radio button list,
Check box list,
Bulleted list.
These control let a user choose from one or more items from the list. List boxes
and drop-down lists contain one or more list items.
These lists can be loaded either by code or by the ListItemCollection editor.
5. Image Control
The image control is used for displaying images on the web page, or some alterna
tive text,
if the image is not available.
Q. View state in asp.net?
Ans. ViewState
Another approach to saving data for the user, is the ViewState. As described els
ewhere in this tutorial,
the ViewState allows ASP.NET to repopulate form fields on each postback to the s
erver, making sure that a form is not automatically
cleared when the user hits the submit button. All this happens automatically, un
less you turn it off, but you can actually use the ViewState
for your own purposes as well. Please keep in mind though, that while cookies a
nd sessions can be accessed from all your pages on your website,
ViewState values are not carried between pages. Here is a simple example of usi
ng the ViewState to carry values between postbacks:
View State is the method to preserve the Value of the Page and Controls between
round trips. It is a Page-Level State Management technique.
View State is turned on by default and normally serializes the data in every con
trol on the page regardless of whether it is actually used
during a post-back.
Q. = Cashing in asp.net?
Ans. Caching is a technique of storing frequently used data/information in memor
y, so that, when the same data/information
is needed next time, it could be directly retrieved from the memory instead of
being generated by the application.
Caching is extremely important for performance boosting in ASP.NET,
Caching in ASP.Net
ASP.NET provides the following different types of caching:
Output Caching : Output cache stores a copy of the finally rendered HTML pages o
r part of pages sent to the client.
When the next client requests for this page, instead of regener
ating the page, a cached copy of the page is sent,
thus saving time.

Data Caching : Data caching means caching data from a data source. As long as th
e cache is not expired, a request for the data
will be fulfilled from the cache. When the cache is expired, fre
sh data is obtained by the data source and the cache
is refilled.
Object Caching : Object caching is caching the objects on a page, such as data-b
ound controls. The cached data is stored in server memory.
Class Caching : Web pages or web services are compiled into a page class in the
assembly, when run for the first time. Then the assembly is
cached in the server. Next time when a request is made for the p
age or service, the cached assembly is referred to.
When the source code is changed, the CLR recompiles the assembly
.
Configuration Caching : Application wide configuration information is stored in
a configuration file. Configuration caching stores the
configuration information in the server memory.
Q. Define response. Redirect
Ans. Response.Redirect

server. Transfer method?

Response.Redirect() will send you to a new page, update the address bar and add
it to the Browser History. On your browser you can click back.
It redirects the request to some plain HTML pages on our server or to some other
web server.
It causes additional roundtrips to the server on each request.
It doesn t preserve Query String and Form Variables from the original request.
It enables to see the new redirected URL where it is redirected in the browser (
and be able to bookmark it if it s necessary).
Response. Redirect simply sends a message down to the (HTTP 302) browser.
Server.Transfer
Server.Transfer() does not change the address bar, we cannot hit back.One should
use Server.Transfer() when he/she doesn t want the user to see where he is going.
Sometime on a "loading" type page.
It transfers current page request to another .aspx page on the same server.
It preserves server resources and avoids the unnecessary roundtrips to the serve
r.
It preserves Query String and Form Variables (optionally).
It doesn t show the real URL where it redirects the request in the users Web Brows
er.
Server.Transfer happens without the browser knowing anything, the browser reques
t a page, but the server returns the content of another.
Q. What are the types of SQL command?
Ans.==
SQL commands are instructions, coded into SQL statements, which are used to comm
unicate with the database to perform specific tasks,
work, functions and queries with data.
SQL commands can be used not only for searching the database but also to perform
various other functions like, for example,
you can create tables, add data to tables, or modify data, drop the table, set
permissions for users. SQL commands are grouped
into four major categories depending on their functionality:
Data Definition Language (DDL) - These SQL commands are used for creating, modif
ying, and dropping the structure of database objects.

The commands are CREATE, ALTER, DROP, RENAME, an


d TRUNCATE.
Data Manipulation Language (DML) - These SQL commands are used for storing, retr
ieving, modifying, and deleting data.
These Data Manipulation Language commands are: S
ELECT, INSERT, UPDATE, and DELETE.
Transaction Control Language (TCL) - These SQL commands are used for managing ch
anges affecting the data. These commands are COMMIT,
ROLLBACK, and SAVEPOINT.
Data Control Language (DCL) - These SQL commands are used for providing security
to database objects. These commands are GRANT and REVOKE.
Session Control Statements (SCS) - Session control statement are manage properti
es dynamically of a user session. ALTER SESSION , SET ROLE.
Q.= What is ADO.net
Ans.== ADO.NET provides a bridge between the front end controls and the back end
database. The ADO.NET objects encapsulate all the data access
operations and the controls interact with these objects to display data, thus hi
ding the details of movement of data.
ADO.NET is an object-oriented set of libraries that allows you to interact with
data sources. Commonly, the data source is a database,
but it could also be a text file, an Excel spreadsheet, or an XML file. For the
purposes of this tutorial, we will look at ADO.NET as a
way to interact with a data base.
As you are probably aware, there are many different types of databases available
. For example, there is Microsoft SQL Server,
Microsoft Access, Oracle, Borland Interbase, and IBM DB2, just to name a few. To
further refine the scope of this tutorial, all of
the examples will use SQL Server.
Q. == Connection string using ADO.net?
Ans. ==Connection String is a normal String representation which contains Databa
se connection information to establish the connection
between Database and the Application. The Connection String includes parameters
such as the name of the driver, Server name and Database name ,
as well as security information such as user name and password.
Usually Data Providers use a connection string containing a collection of parame
ters to establish the connection with the database through
applications. The .NET Framework provides mainly three data providers, they are
Microsoft SQL Server
OLEDB
ODBC
Here you can see how to make a connection string to the following ADO.NET Data P
roviders.
Microsoft SQL Server Connection String
connetionString="Data Source=ServerName;Initial Catalog=Databasename;
User ID=UserName;Password=Password"
OLEDB Data Provider Connection String
connetionString="Provider=Microsoft.Jet.OLEDB.4.0;

Data Source=yourdatabasename.mdb;"
ODBC Connection String
connetionString="Driver={Microsoft Access Driver (*.mdb)};
DBQ=yourdatabasename.mdb;"
You have to provide the necessary connection information to the Connection Strin
g attributes.
Q. ==What is web.net config file.
Ans. ==Web.config is the main settings and configuration file for an ASP.NET web
application. It is an XML document that resides in the
root directory of the site or application and contains data about how the web a
pplication will act. This information controls module loading,
security configuration, session state configuration, and application language an
d compilation settings. Web.config files can also contain
application specific items such as database connection strings.
Q. == How to establish a databases connection using ADO.net? (SQL connection cla
ss , SQL command class)
Ans. ==The Connection Object is a part of ADO.NET Data Provider and it is a uniq
ue session with the Data Source. The Connection Object
is Handling the part of physical communication between the C# application and th
e Data Source.
The Connection Object connect to the specified Data Source and open a connection
between the C# application and the Data Source,
depends on the parameter specified in the Connection String . When the connectio
n is established, SQL Commands will execute with the
help of the Connection Object and retrieve or manipulate data in the Data Sourc
e.
Once the Database activity is over , Connection should be closed and release the
Data Source resources .
If you have a named instance of SQL Server, you'll need to add that as well.
"Server=localhost\sqlexpress"
When the connection is established , SQL Commands will execute with the help of
the Connection Object and retrieve or manipulate
the data in the database. Once the Database activities is over , Connection shou
ld be closed and release the Data Source resources

You might also like