Last post May 17, 2005 01:48 PM by jarodxp
May 17, 2005 01:48 PM|jarodxp|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();
ConString = "Data Source=192.168.0.22;Initial Catalog=Northwind;User
mySqlCon.ConnectionString = ConString;
sqlText = "select * from Products";
mysqlComm.Connection = mySqlCon;
mysqlComm.CommandText = sqlText;
SqlDataAdapter myDataAdapter = new SqlDataAdapter(mysqlComm);
DataTable atable = new DataTable();
GridView1.DataSource = mydataset;
// this.SqlDataSource1.ProviderName = mydataset;
GridView1.AllowPaging = true;
GridView1.AllowSorting = true;
Who can help me?