Data source controls in asp net Part 2











>> YOUR LINK HERE: ___ http://youtube.com/watch?v=rqR6aps_ppk

Text version of the video • http://csharp-video-tutorials.blogspo... • Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help. •    / @aarvikitchen5572   • Slides • http://csharp-video-tutorials.blogspo... • All GridView Text Articles • http://csharp-video-tutorials.blogspo... • All GridView Slides • http://csharp-video-tutorials.blogspo... • All Dot Net and SQL Server Tutorials in English • https://www.youtube.com/user/kudvenka... • All Dot Net and SQL Server Tutorials in Arabic •    / kudvenkatarabic   • The following are some of the different data source controls that are available in asp.net. • SqlDataSource - Use to work with SQL Server, OLE DB, ODBC, or Oracle databases • ObjectDataSource - Use to work business objects, that manages data • AccessDataSource - Use to work with Microsoft Access • XmlDataSource - Use to work with XML files • LinqDataSource - Enables us to use LINQ, to retrieve and modify data from a data object • EntityDataSource - Use to work with Entity Data Model • Prior to the introduction of data source controls, developers had to write a few lines of code to retrieve and bind data with data-bound controls like DataGrid, GridView, DataList etc. With the introduction of these data source controls, we don't have to write even a single line of code, to retrieve and bind data to a data-bound control. • SqlDataSource - Use to work with SQL Server, OLE DB, ODBC, or Oracle databases • ObjectDataSource - Use to work business objects, that manages data • AccessDataSource - Use to work with Microsoft Access • XmlDataSource - Use to work with XML files • LinqDataSource - Enables us to use LINQ, to retrieve and modify data from a data object • EntityDataSource - Use to work with Entity Data Model • We will discuss about, each of these data source controls in our upcoming videos. • To bind data to a data bound control, like gridview there are 2 ways • 1. Without using data-source controls • 2. Using data-source controls • If we are not using data source controls, then we have to write code to • 1. Read connection string • 2. Create connection object • 3. Create SQL Command object • 4. Execute the command • 5. Retrieve and bind the results to the data-bound control. • Code to bind data to a gridview control, without using data-source controls: • string cs = ConfigurationManager.ConnectionStrings[ DBConnectionString ].ConnectionString; • using (SqlConnection con = new SqlConnection(cs)) • { • SqlCommand cmd = new SqlCommand( Select * from tblProducts , con); • con.Open(); • GridView1.DataSource = cmd.ExecuteReader(); • GridView1.DataBind(); • } • If we are using data source controls, we don't have to write even a single line of code. All, you have to do is, drag and drop a data-source control on the webform. Configure the data-source control to connect to a data source and retrieve data. Finally associate the data-source control, to a data-bound control using DataSourceID property. • Points to remember: • 1. ConnectionString property of the SqlDataSource control is used to determine the database it has to connect, to retrieve data • 2. SelectCommand property specifies the command that needs to be executed. • 3. DataSource control is associated, with the gridview control, using DataSourceID property of the GridView control. • Please Note: All databound controls has DataSourceID property. A few examples of databound controls include • 1. DropDownList • 2. CheckBoxList • 3. Repeater • 4. DataList etc...

#############################









New on site
Content Report
Youtor.org / YTube video Downloader © 2025

created by www.youtor.org