Typed Dataset Using Asp.net 3.5
Before starting we will remember in Dotnet frame work 2.0. In this it will create only xsd and class file for that. But it will not create Adapters for retrieving dataset. We should use Sqldataadapter for getting the data. But in Asp.net 3.5 frame work it will create data adapter for that xsd. So we can get the typed dataset via adapter instead of getting from Sqldataadapter. See the step by step explanations with examples.
Step 1:
Create one employee database with table name called “contact” which has created for you. Open that database in server explorer of visual studio 2008. See picture A
Picture A
Step 2:
Create Contact.xsd file through add file option in project file. See picture B
Picture B
Step 3:
Drag and drop contact table in to the contact.xsd screen. After waiting few seconds it will create Contact.xsd file automatically. Now you can see in picture C
Picture C
Step 4
Writing few lines of code assigning this typed data values in gridview. See picture as well as the code to retrieve the typed dataset. Create one aspx page with gridview control. I am going to write the code in page load event for that page.
Example:
protected void Page_Load(object sender, EventArgs e)
{
ContactTableAdapters.ContactTableAdapter Dataadapt = new Dotnetspider.ContactTableAdapters.ContactTableAdapter();
grdlist.DataSource = Dataadapt.GetData();
grdlist.DataBind();
}
Note: ContactTableAdapter class will create automatically. This is the one main difference between frame work 2.0 and framework 3.5. But in 2.0 frame work will not create.
Happy Coding
By
Bala
Note:Images will update soon. Sorry for the inconvenience.