How to use ObjectDataSource control in applications

Hi friend,Today we will learn how to configure and use ObjectDataSource control in applications .This control represents the business objects and allow you to use the objectDataSource control in conjunction with a data-bound control to display ,edit and sort the data on a web page with little or no code .The control is used to create web applications that rely on the middle-tier objects to manage data. I have already explained following data source as given below :-
There are some steps to implement the whole concepts as given below:-
Step 1:- First create table(student) in your sql database and insert some values as shown below:-

Step 2:- Now open Your visual studio-->Create a ASP.NET Empty Website-->Open Solution Explorer-->Add a Page(Default.aspx).
Step 3:-Now open Solution Explorer-->Add a Class1.cs file --> write the following c# codes as given below:-

using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Data.SqlClient;

/// <summary>
/// Summary description for Class1
/// </summary>
public class Class1
 public DataSet get()
        SqlConnection con = new SqlConnection("Data Source=RAMASHANKAR-PC;Initial Catalog=master;Integrated Security=True");
        SqlDataAdapter da = new SqlDataAdapter("Select *from student", con);
        DataSet ds = new DataSet();
        return ds;

Step 4:- Now Drag and Drop ObjectDataSource and GridView controls from toolBox  
as shown below:-

Step 5:-Now Configuration the ObjectDataSource as shown in step 4 and choose a Method as shown below:-

Step 6:- Now open the arrow of grid view control--> select ObjectDataSource1 as shown below:-

Step 6:-Now Run the application (Press F5)--> You will see the following output as shown below:-

For More...
  1. Learn .NET Interview questions and Answers
  2. oops concepts in c#
  3. How to add Captcha image in website
  4. Learn MVC Concepts with example
  5. Learn Crystal report concepts with examples
Download Whole attached file


Post a Comment

Powered by Blogger.