datagrid绑定不是一个固定的表.出错提示:无效的 CurrentPageIndex 值。它必须大于等于 0 且小于 PageCount
要查询全部时不考虑类别字段.用下拉列表框传递leibie变量查询具体一个类别,
当查完一个类别的数据后查别一个类别,按下一页提出出错.请帮忙!
无效的 CurrentPageIndex 值。它必须大于等于 0 且小于 PageCount
private void binddata(string sortorder)
{
SqlConnection myconnection = new SqlConnection(con);
if (leibie=="0")
mycommand="select * from 管理用户";
else
mycommand="select * from 管理用户 where (类别='"+leibie+"')";
SqlDataAdapter da=new SqlDataAdapter(mycommand,myconnection);
DataSet ds=new DataSet();
da.Fill(ds,"ll");
DataGrid1.DataSource=ds.Tables["ll"].DefaultView.Sort=sortorder;
DataGrid1.DataSource=ds.Tables["ll"].DefaultView;
DataGrid1.DataBind();
}
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex=e.NewPageIndex ;
binddata("编号");
}