Hi friend,Today we will learn how to configure and use ObjectDataSource control in asp.net 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 :-
- How to use SqlDataSource control in asp.net
- How to use AccessDataSource control in asp.net
- How to use XmlDataSource control in asp.net
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();
da.Fill(ds);
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...
- Learn .NET Interview questions and Answers
- oops concepts in c#
- How to add Captcha image in asp.net website
- Learn MVC Concepts with example
- Learn Crystal report concepts with examples
Download
0 comments:
Post a Comment