Click here to Skip to main content
15,887,917 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,

Iam facing problem with creating DataSet.Xsd, and How to Access data from the DataSet .Xsd file.
Posted

 
Share this answer
 
v2
I Solved this Issue.

Below is the Code Snippet........

Typed DataSet Example Edit,Delete,Update to the DataSet.xsd file .


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Data.OleDb;
using System.Data.Odbc;
using System.Data;
using System.IO;
using System.Text;
using System.ComponentModel.Design.Serialization;


public partial class _Default : System.Web.UI.Page
{



protected void Page_Load(object sender, EventArgs e)
{


ProductDataSetTableAdapters.ProductsTableAdapter adapter=new ProductDataSetTableAdapters.ProductsTableAdapter ();
ProductDataSet.ProductsDataTable table = adapter.GetData();
GridView1.DataSource = table;
GridView1.DataBind();


}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
ProductDataSetTableAdapters.ProductsTableAdapter adapter = new ProductDataSetTableAdapters.ProductsTableAdapter();
ProductDataSet.ProductsDataTable table = adapter.GetData();

GridView1.DataSource = table;
GridView1.DataBind();


}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{

}
protected void GridView1_PageIndexChanged(object sender, EventArgs e)
{
//GridView1.PageIndex = e.NewPageIndex;
//bindGridView();

}



protected void BtnCreate_Click(object sender, EventArgs e)
{
ProductDataSetTableAdapters.ProductsTableAdapter adapter = new ProductDataSetTableAdapters.ProductsTableAdapter();
ProductDataSet.ProductsDataTable table = adapter.GetData();
//adapter.InsertProduct("a", 2, 2, "10.2", 1, 1, 100, 1, true);
adapter.InsertProduct(Convert.ToString(TextBox2.Text), Convert.ToInt32(TextBox3.Text),Convert.ToInt32(TextBox4.Text), Convert.ToString(TextBox5.Text),Convert.ToInt16(TextBox6.Text),short.Parse(TextBox7.Text), short.Parse(TextBox8.Text),short.Parse(TextBox9.Text),Convert.ToBoolean(CheckBox1.Checked));
//adapter.DeleteQuery(94);
//SqlCommand command = adapter.

GridView1.DataSource = table;
GridView1.DataBind();
}
protected void BtnCancel_Click(object sender, EventArgs e)
{
//foreach (Control c in this.Controls)

// (c as TextBox).Clear();

}


protected void On_RowEditing(object sender, GridViewEditEventArgs e)
{
LinkButton EditButton = GridView1.Rows[e.NewEditIndex].FindControl("lnkDelete") as LinkButton;
int productID = Convert.ToInt32(EditButton.CommandArgument);
ProductDataSetTableAdapters.ProductsTableAdapter adapter = new ProductDataSetTableAdapters.ProductsTableAdapter();
ProductDataSet.ProductsDataTable table = adapter.GetData();
adapter.UpdateQuery(Convert.ToString(TextBox2.Text), Convert.ToInt32(TextBox3.Text), Convert.ToInt32(TextBox4.Text), Convert.ToString(TextBox5.Text), Convert.ToInt16(TextBox6.Text), short.Parse(TextBox7.Text), short.Parse(TextBox8.Text), short.Parse(TextBox9.Text), Convert.ToBoolean(CheckBox1.Checked),productID);
GridView1.DataSource = table;
GridView1.DataBind();


}

protected void On_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
LinkButton DeleteButton = GridView1.Rows[e.RowIndex].FindControl("lnkDelete") as LinkButton;
int ProductID = Convert.ToInt32(DeleteButton.CommandArgument);
ProductDataSetTableAdapters.ProductsTableAdapter adapter = new ProductDataSetTableAdapters.ProductsTableAdapter();
ProductDataSet.ProductsDataTable table = adapter.GetData();
adapter.DeleteQuery(ProductID);
GridView1.DataSource = table;
GridView1.DataBind();


}

}



-----------------Prasanna Y
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900