namespace WebApplication1
{
public partial class About : Page
{
protected void Page_Load(object sender, EventArgs e)
{
string command = "select * from maintenance.dbo.components"; DataTable dt = DBHelpers.DBHelper.GetDataTable(command);
int n = dt.Rows.Count;
int m = dt.Columns.Count;
this.GridView1.DataSource = dt;
GridView1.DataBind();
}
}
}
public static DataTable GetDataTable(string safeSql)
{
DataTable dt = new DataTable();
DbCommand cmd = DbParaFactory.GetDbCommand();
cmd.Connection = Connection;
cmd.CommandType = CommandType.Text;
cmd.CommandText = safeSql; DbDataAdapter da = DbParaFactory.GetDbDataAdapter();
da.SelectCommand = cmd; da.Fill(dt);
return dt;
} public static DataAdapter GetDataAdapter(string safeSql)
{
DbCommand cmd = DbParaFactory.GetDbCommand();
cmd.Connection = Connection;
cmd.CommandType = CommandType.Text;
cmd.CommandText = safeSql; DbDataAdapter da = DbParaFactory.GetDbDataAdapter();
da.SelectCommand = cmd; return da;
}用变量m和n来看dt中都是有数据的,但是实际不显示。我是母版页内容页上放置的gridview,母版页内容页下面pageload函数什么都没有,是不是因为这个原因才不显示?
新手上路,求指点。
{
public partial class About : Page
{
protected void Page_Load(object sender, EventArgs e)
{
string command = "select * from maintenance.dbo.components"; DataTable dt = DBHelpers.DBHelper.GetDataTable(command);
int n = dt.Rows.Count;
int m = dt.Columns.Count;
this.GridView1.DataSource = dt;
GridView1.DataBind();
}
}
}
public static DataTable GetDataTable(string safeSql)
{
DataTable dt = new DataTable();
DbCommand cmd = DbParaFactory.GetDbCommand();
cmd.Connection = Connection;
cmd.CommandType = CommandType.Text;
cmd.CommandText = safeSql; DbDataAdapter da = DbParaFactory.GetDbDataAdapter();
da.SelectCommand = cmd; da.Fill(dt);
return dt;
} public static DataAdapter GetDataAdapter(string safeSql)
{
DbCommand cmd = DbParaFactory.GetDbCommand();
cmd.Connection = Connection;
cmd.CommandType = CommandType.Text;
cmd.CommandText = safeSql; DbDataAdapter da = DbParaFactory.GetDbDataAdapter();
da.SelectCommand = cmd; return da;
}用变量m和n来看dt中都是有数据的,但是实际不显示。我是母版页内容页上放置的gridview,母版页内容页下面pageload函数什么都没有,是不是因为这个原因才不显示?
新手上路,求指点。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货