Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 17, 2005 12:48 PM by jarodxp
Member
25 Points
5 Posts
May 17, 2005 12:48 PM|LINK
I want to use the dataset as the datasource of GridView, but when I use the dataset, the
Gridview couldn't sort and paging. the exception are "The GridView 'GridView1' fired event PageIndexChanging which wasn't
handled." and "The GridView 'GridView1' fired event Sorting which wasn't handled. " my code is " protected void Page_Load(object sender, EventArgs e) {
} protected void Button1_Click(object sender, EventArgs e) { SqlConnection mySqlCon = new SqlConnection(); DataSet mydataset = new DataSet(); SqlCommand mysqlComm = new SqlCommand(); string ConString; ConString = "Data Source=192.168.0.22;Initial Catalog=Northwind;User
ID=sa;Password=data"; mySqlCon.ConnectionString = ConString; // mySqlCon.Open(); string sqlText; sqlText = "select * from Products"; mysqlComm.Connection = mySqlCon; mysqlComm.CommandText = sqlText;
SqlDataAdapter myDataAdapter = new SqlDataAdapter(mysqlComm); mySqlCon.Open(); mysqlComm.ExecuteNonQuery(); myDataAdapter.Fill(mydataset, "Product"); DataTable atable = new DataTable();
GridView1.DataSource = mydataset; // this.SqlDataSource1.ProviderName = mydataset; GridView1.AllowPaging = true; GridView1.AllowSorting = true; GridView1.DataBind(); mySqlCon.Close(); } " Who can help me?
jarodxp
Member
25 Points
5 Posts
How to sort and paging with GridView ?
May 17, 2005 12:48 PM|LINK
I want to use the dataset as the datasource of GridView, but when I use the dataset, the
Gridview couldn't sort and paging.
the exception are "The GridView 'GridView1' fired event PageIndexChanging which wasn't
handled." and "The GridView 'GridView1' fired event Sorting which wasn't handled. "
my code is
"
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection mySqlCon = new SqlConnection();
DataSet mydataset = new DataSet();
SqlCommand mysqlComm = new SqlCommand();
string ConString;
ConString = "Data Source=192.168.0.22;Initial Catalog=Northwind;User
ID=sa;Password=data";
mySqlCon.ConnectionString = ConString;
// mySqlCon.Open();
string sqlText;
sqlText = "select * from Products";
mysqlComm.Connection = mySqlCon;
mysqlComm.CommandText = sqlText;
SqlDataAdapter myDataAdapter = new SqlDataAdapter(mysqlComm);
mySqlCon.Open();
mysqlComm.ExecuteNonQuery();
myDataAdapter.Fill(mydataset, "Product");
DataTable atable = new DataTable();
GridView1.DataSource = mydataset;
// this.SqlDataSource1.ProviderName = mydataset;
GridView1.AllowPaging = true;
GridView1.AllowSorting = true;
GridView1.DataBind();
mySqlCon.Close();
}
"
Who can help me?