private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
this.topDga();
}
// 在此处放置用户代码以初始化页面
}
public void topDga()
{
this.topGrid.DataKeyField="client_ID";
this.topGrid.DataSource=operation.topSelect();
Session["exceltop"]=operation.topSelect();
// Session是我导出EXCEL用的,没问题
this.topGrid.DataBind();
}
//这是页面的绑定,且选为运行时自动创建列//下面是CS文件的
public static DataTable topSelect()
{
SqlConnection con=operation.createConnection();
//上面的con调用的连接方法没问题
SqlDataAdapter adapter=new SqlDataAdapter();
adapter.SelectCommand=con.CreateCommand();
adapter.SelectCommand.CommandText="select client_ID,client_Admin,client_Num,client_Name,client_Date from client_Info";
DataSet dtst=new DataSet();
adapter.Fill(dtst,"client_Info");
con.Close();
return dtst.Tables["chlient_Info"];
}
{
if(!IsPostBack)
{
this.topDga();
}
// 在此处放置用户代码以初始化页面
}
public void topDga()
{
this.topGrid.DataKeyField="client_ID";
this.topGrid.DataSource=operation.topSelect();
Session["exceltop"]=operation.topSelect();
// Session是我导出EXCEL用的,没问题
this.topGrid.DataBind();
}
//这是页面的绑定,且选为运行时自动创建列//下面是CS文件的
public static DataTable topSelect()
{
SqlConnection con=operation.createConnection();
//上面的con调用的连接方法没问题
SqlDataAdapter adapter=new SqlDataAdapter();
adapter.SelectCommand=con.CreateCommand();
adapter.SelectCommand.CommandText="select client_ID,client_Admin,client_Num,client_Name,client_Date from client_Info";
DataSet dtst=new DataSet();
adapter.Fill(dtst,"client_Info");
con.Close();
return dtst.Tables["chlient_Info"];
}
con.Close();
return dtst.Tables["chlient_Info"];
Fill的时候的表名是client_Info,而你返回的是chlient_Info.
应该是return dtst.Tables["client_Info"];