GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Microsoft  >  ADO.NET 2.0
Go To First  |  Previous Question  |  Next Question 
 ADO.NET 2.0  |  Question 5 of 19    Print  

What is the Best Practice for binding Controls [Data in the data grid is to be binded with the controls of some form ] ?


  
Total Answers and Comments: 2 Last Update: March 27, 2006   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
March 27, 2006 14:24:27   #1  
rashid Member Since: March 2006   Contribution: 7    

RE: What is the Best Practice for binding Controls ...
public partial class UseDataList : System.Web.UI.Page
{
protected DataTable GetInventory()
{

String strConnection
@ Provider Microsoft.Jet.OLEDB.4.0;
DataSource C:\\northwind.mdb ;

DbProviderFactory f
DbProviderFactories.GetFactory( System.Data.OleDb );

DbConnection connection f.CreateConnection();
connection.ConnectionString strConnection;

connection.Open();

DbCommand command f.CreateCommand();
command.CommandText Select * from DotNetReferences ;
command.Connection connection;

IDataReader reader command.ExecuteReader();

DataTable dt new DataTable();
dt.Load(reader);
reader.Close();
connection.Close();
connection.Dispose();

return dt;
}

protected DataTable BindToinventory()
{
DataTable dt;
dt this.GetInventory();
this.DataList1.DataSource dt;
this.DataBind();
return dt;
}


 
Is this answer useful? Yes | No
March 27, 2006 14:31:02   #2  
rashid Member Since: March 2006   Contribution: 7    

RE: What is the Best Practice for binding Controls ...

Some user controls are entirely self contained for example a user control displaying current stock quotes does not need to interact with any other content on the page. Other user controls will contain buttons to post back. Although it is possible to subscribe to the button click event from the containing page doing so would break some of the object oriented rules of encapsulation. A better idea is to publish an event in the user control to allow any interested parties to handle the event.

This technique is commonly referred to as event bubbling since the event can continue to pass through layers starting at the bottom (the user control) and perhaps reaching the top level (the page) like a bubble moving up a champagne glass.


 
Is this answer useful? Yes | No

 Related Questions

Recordset provides data one row at a time.Dataset is a data structure which represents the complete table data at same time.Recordset has the logic to update and manipulate dataDataset is just a data store 
Latest Answer : Recordset is the Read only & forward only mechanism. But Dataset is the Editable. Recordset is connection oriented and Dataset need connection once to dump the data from the data base. Dataset holds more than one table at a time but recordset holds only ...

ADO.NET Does Not Depend On Continuously Live ConnectionsDatabase Interactions Are Performed Using Data CommandsData Can Be Cached in DatasetsDatasets Are Independent of Data SourcesData Is Persisted as 
Latest Answer : ado.net uses dataset for accessing the data , since the dataset is created in client side there is no need of connection at the time of working on dataset ,to the server(where the database is present),  so this makes the data accessing ...

Latest Answer : The achive the best performance in databiding always use Dim _Li as ListItemWhile _Reader.Read()  _Li=new ListItem(_Reader(1),_Reader(0))  _dropdownList.Items.add(_Li)End WhileYou can check with performance counter to check in real. CheersSanjarniyazi.khan@gmail.com ...

What is the Best Practice for binding Controls [Data in the data grid is to be binded with the controls of some form ] ?

Latest Answer : Control which drives from BaseDataBoundControl Class  Serves as the base class for controls that bind to data using an ASP.NET data source control. ...
Read Answers (1) | Asked by : neelu

The grid view consists of 3 columns which are combo Boxes. I want the string in the 1st column. 
Latest Answer : ((DropDownList)GV_chart.Rows[e.RowIndex].FindControl("Dcity1"));Here GV_Chart is the id of Grid View And DCity is the Name of the dropdown list ...
Read Answers (3) | Asked by : Bharath

Imports System.Data.SqlClientPublic Class Form1Dim cn As New SqlConnection("server=.;database=atten;uid=sa;pwd=sa;")Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) 
Latest Answer : Column Name do not allow numeric values.choose Charecters. ...

Latest Answer : What I understand from your question is that, you have the image content in your data base and wants to read it from there and show it to web page.If I am right in my perception, then a simple solution would be as follows.Setup a virtual directory and ...


 Sponsored Links

 
Related Articles

Breaking up XML into Relational Data

Breaking up XML into Relational Data While the preceding example shows how to construct an XML representation over relational data the example in this section illustrates how you can shred XML data back into relational data This reverse operation can be useful if your application works with relation
 

Querying Data with Oracle XQuery

Querying Data with Oracle XQuery Starting with Oracle Database 10g Release 2 you can take advantage of a full featured native XQuery engine integrated with the database With Oracle XQuery you can accomplish various tasks involved in developing PHP Oracle XML applications operating on any kind of dat
 

Retrieving XML Data

Retrieving XML DataTo retrieve XML data from an XMLType table you can use a SELECT SQL statement just as you would if you had to query a relational table For example to select the employee with the id set to 100 from the employees XMLType table discussed in the preceding section you might issue the
 

Using XMLType for Handling XML Data in the Database

Using XMLType for Handling XML Data in the Database Being an object type XMLType can not only be used to store XML data in the database but also to operate on that data via its built in methods Regardless of the storage model you choose XMLType provides a set of XML specific methods to operate on XM
 

Using Oracle Database for Storing, Modifying, and Retrieving XML Data

Using Oracle Database for Storing Modifying and Retrieving XML Data With Oracle XML DB you have various XML storage and XML processing options allowing you to achieve the required level of performance and scalability One of the most interesting things about Oracle XML DB is that it allows you to per
 

ODP.NET - Techniques to Improve Performance while Retrieving Data

ODP NET Techniques to Improve Performance while Retrieving Data Performance tuning is a great subject in Oracle Volumes of books would not be enough to cover every aspect of performance tuning in Oracle However in this section we will only discuss the fundamental performance techniques while working
 

ODP.NET - Populating a Dataset with a Single Data Table

ODP NET Populating a Dataset with a Single Data Table A dataset is simply a group of data tables These data tables can be identified with their own unique names within a dataset You can also add relations between data tables available in a dataset mosgoogle The following code gives you the details o
 

ODP.NET - Retrieving Typed Data

ODP NET Retrieving Typed Data While retrieving values from OracleDataReader we can extract information available in individual columns of a particular row either by using column ordinal position values or column names mosgoogle Retrieving Typed Data Using Ordinals ODP NET provides data specific enum
 

ODP.NET - Retrieving Multiple Rows on to the Grid

ODP NET Retrieving Multiple Rows on to the Grid In the previous section we tried to retrieve only one row using OracleDataReader In this section we will try to retrieve more than one row or a result set and populate a DataGridView on a WinForm mosgoogle The following code lists out the details of al
 

ODP.NET - Retrieving Data Using OracleDataReader

ODP NET Retrieving Data Using OracleDataReader OracleDataReader is simply a read only and forward only result set It works only if the database connection is open and it makes sure that the connection is open while you are retrieving data As the data that it retrieves is read only it is a bit faster
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape