Monday, 17 March 2014

Interview Q & A on DataBound Controls in Asp.Net(Part 2)

 1.What is event bubbling ?
A.
Server controls like Datagrid, DataList, Repeater can have other child controls inside
  them. Example DataGrid can have combo box inside datagrid. These child control do not
  raise there events by themselves, rather they pass the event to the container parent (which
  can be a datagrid, datalist, repeater), which passed to the page as “ItemCommand” event.
  As the child control send there events to parent this is termed as event bubbling.

2.What is AppSetting Section in “Web.Config” file ?
A.
Web.config file defines configuration for a webproject. Using “AppSetting” section we
  can define user defined values.
  Example below defined is “ConnectionString” section
  which will be used through out the project for database connection.
  <configuration>
  <appSettings>
  <add key="ConnectionString" value="server=xyz;pwd=www;database=testing" />
  </appSettings>

3.What’s the use of SmartNavigation property ?
A.
It’s a feature provided by ASP.NET to prevent flickering and redrawing when the page is
  posted back.
  Note:- This is only supported for IE browser. Project’s who have browser compatibility as
  requirements have to think some other ways of avoiding flickering.

4.How can you enable automatic paging in DataGrid ?
A.
Following are the points to be done in order to enable paging in Datagrid :-
  v Set the “AllowPaging” to true.
  v In PageIndexChanged event set the current pageindex clicked.
  Note:- The answers are very short, if you have implemented practically its just a revision.
  If you are fresher just make sample code using Datagrid and try to implement this
  functionality.

5.What’s difference between Datagrid, Datalist and repeater?
A.
Datagrid, Datalist and Repeater are all ASP.NET data Web controls.
  They have many things in common like DataSource Property, DataBind Method
  ItemDataBound and ItemCreated.

  When you assign the DataSource Property of a Datagrid to a DataSet then each DataRow
  present in the DataRow Collection of DataTable is assigned to a corresponding
  DataGridItem and this is same for the rest of the two controls also. But The HTML code
  generated for a Datagrid has an HTML TABLE <ROW> element created for the particular
  DataRow and its a Table form representation with Columns and Rows.

  For a Datalist its an Array of Rows and based on the Template Selected and the
  RepeatColumn Property value We can specify how many DataSource records should
  appear per HTML <table> row. In short in datagrid we have one record per row, but in
  datalist we can have five or six rows per row.

  For a Repeater Control, the Datarecords to be displayed depends upon the Templates
  specified and the only HTML generated is the due to the Templates.

  In addition to these, Datagrid has a in-built support for Sort, Filter and paging the Data,
  which is not possible when using a DataList and for a Repeater Control we would require
  to write an explicit code to do paging.

6.What is the difference between eval and bind?
A.
1.The Eval method evaluates late-bound data expressions in the templates of data-bound controls
    such as the GridView, DetailsView, and FormView controls and the Bind method is typically used
    with input controls such as the TextBox control rendered by a GridView row in edit mode.
  2.Eval is a protected method defined on the TemplateControl class, from which the Page class is derived.
    Bind is a new ASP.NET 2.0 databinding keyword. It's not a method of any specific class.
  3.Bind() is used to two-way databinding. So when used with the proper type of datasource,
    it will pull the altered values out of the GridView or other control and save them back to the database.
    Eval() is a one-way, "read only" way to bind the values.

7.A data-bound control connects to a data source control through its ___________ property?
A. 
DataSourceID

8.What are the best practices to follow to secure connection strings in an ASP.NET web application?
A.
1. Always store connection strings in the site's Web.config file. Web.config is very secure.
  Users will not be able to access web.config from the browser.
  2. Do not store connection strings as plain text. To help keep the connection to your database server secure,
  it is recommended that you encrypt connection string information in the configuration file.
  3. Never store connection strings in an aspx page.
  4. Never set connection strings as declarative properties of the SqlDataSource control or other data source controls.

9.A _____________ control bind to a data source control and automatically fetch data at the appropriate time in the page request lifecycle.
A.
DataBound control.

10.______________ Controls enable rich capabilities for retrieving and modifying data, including querying, sorting, paging, filtering, updating, deleting, and inserting.
A.
DataSource control.

11.what is expression Builder? Why would you use it?
A.
ASP.NET 2.0 introduces a declarative new syntax for referencing code to substitute values into the page,
  called Expression Builders. ASP.NET 2.0 includes expression builders for referencing string resources
  for localization, connection strings, application settings, and profile values. You can also write your own
  expression builders to create your own custom syntax to substitute values in a page rendering.

12.what is simple Data bound control and Composite data bound control?
A.
Composite Data Controls
  1.Composite data controls are not directly transformed to a single HTML element
  Consist of different templates which is used to define layout and style flexibly
  2.More data fields can be bound to controls
  3.Support bi-directional data binding.
  Simple Data controls
  1.It takes only 2 fields.1.display value.2.display field.
  And takes only one value.
  2.only 2 fields are bound to controls.
  3.support uni directional data binding.

13.What is AdRotator control?
A.
The AdRotator control is used to display a sequence of ad images.
  This control uses an XML file to store the ad information. The XML file must begin and end with an <Advertisements> tag.

  Inside the <Advertisements> tag there may be several <Ad> tags which defines each ad.

14.what is an item template?
A.
ItemTemplate: ItemTemplate defines how the each item is rendered from data source collection.

15.what is an AlternatingItemTemplate?
A.
AlternatingItemTemplates is used to change the background color and styles of AlternatingItems in DataSource collection

16.what is an HeaderTemplate?
A.
HeaderTemplate is used to display Header text for DataSource collection and apply different styles for header text.

17.what is an FooterTemplate?
A.
FooterTemplate is used to display footer element for DataSource collection

18.what is an SeparatorTemplate?
A.
The <SeparatorTemplate> element can be used to describe a separator between each record

19.what is an repeater?
A.
The Repeater control is used to display a repeated list of items that are bound to the control.
  The Repeater control may be bound to a database table, an XML file, or another list of items.

20. What is the Differene between RowUpdating Event and RowUpdated Event?
 A.
The RowUpdated event is raised when a row's Update button is clicked,
but after the GridView control updates the row.

The RowUpdating event is raised when a row's Update button is clicked,
but before the GridView control updates the row.

21. What is Cascading in DataBound controls?
A.
Cascading in DataBound Controls Refer to the behaviour of a control in occardance
with the other i.e Data of one control is filtered by the other control.
Here Simple data binding plays a very improtant role as they have DisplayField and the ValueField.

22. What are the DataBound Controls that support Insertion?
 A.
Not all DataBound Controls support insertion in order to achive this, the controls should
support 2 way binding so as to perform insertion into the DataSource. Here 2 way binding refers
to Extracting and Inserting the data from and into the DataSource.
below are the list of such controls.

(i)  FormsView
(ii) DetailsView
(iii)DataListView

Above controls support Grouping,Paging,Inserting,Editing and Deleting of the
data from the DataSource binded to them.

23. how can we find the value of the control present inside the gridView cell?
A. To find the value of the Control we have to follow two steps
                1. Identify the cell position in the grid
                2. use the FindControl() method over in the cell position.

24. What is RowDataBound Event? Explain?
 A.
 RowDataBound is and event of GridView Control that fires when the gridView is binding
with the data. informally, while loading the data into the gridView this event fires.

25. Can we have a DataBound Control within any another? Explain?
 A.
Yes, DataBound Controls can also act as container controls and they can be nested with each other.
a DataBound control that is inside the other becomes a child control, and the control containing it
becomes the parent control.

26. What is DataFormatString Property and List few DataFormatString?
A. 
DataFormatString is a Propery of a BoundField.
it Customizes the input data as per the user Requirment.

Example:
DataFormatString = "{0:D}"
This will give the out put in long date format.

27.What is RepeatLayout, RepeatColumn, RepeatDirection in DataList?
A.
RepeatLayout: The layout that the datalist view should use to repeat items.
RepeatDirection: The Direction to Repeat the items.
RepeatColumn: used to specify number of columns required in datalist to repeat items.

28. What is ItemCommand? Explain?
 A.
ItemCommand is an Event of DataBound control which is fired when a user Click on any button.  

1 comment:

  1. Also read More DataGrid Questions and Answers
    http://allinterviewquestionsandanswerspdf.blogspot.in/2016/06/top-28-datagrid-grid-view-interview.html

    ReplyDelete