asp.net c中的数据集特定表绑定#
我已通过会话将数据集传递到另一个页面,现在我想将数据集的特定表与另一个页面的不同GridView绑定,即我已将数据集作为会话发送到的页面。 在另一页的页面加载中,我正在写作-asp.net c中的数据集特定表绑定#,asp.net,Asp.net,我已通过会话将数据集传递到另一个页面,现在我想将数据集的特定表与另一个页面的不同GridView绑定,即我已将数据集作为会话发送到的页面。 在另一页的页面加载中,我正在写作- if (Session["tt"] != null) { GridView1.DataSource = Session["tt"]; GridView1.DataBind(); } 现在我想将此会话的部分表分配给gridvie
if (Session["tt"] != null)
{
GridView1.DataSource = Session["tt"];
GridView1.DataBind();
}
现在我想将此会话的部分表分配给gridview-
我想要的东西的伪代码是-
if (Session["tt"] != null)
{
GridView1.DataSource = Session["tt"].Tables[0];
GridView1.DataBind();
}
现在怎么做?您需要将会话中的tt对象强制转换为DataSet,然后使用它。见以下代码:
if (!IsPostBack)
{
var ds = Session["tt"] as System.Data.DataSet;
if (ds != null)
{
gvFiles.DataSource = ds.Tables[0];
gvFiles.DataBind();
}
}
希望能有帮助