C# 如何根据条件从数据集中获取数据?

C# 如何根据条件从数据集中获取数据?,c#,asp.net,dataset,C#,Asp.net,Dataset,我已经用这些数据填充了数据集,现在我想从中选择特定的列,但根据条件,我不想每次都连接数据库,只要从数据集中选择就好了。 那个么我如何在数据集上应用条件,比如where子句等呢 数据集 protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataSet dss = CalendarSpotting(); Session["Calendar"] = dss

我已经用这些数据填充了数据集,现在我想从中选择特定的列,但根据条件,我不想每次都连接数据库,只要从数据集中选择就好了。 那个么我如何在数据集上应用条件,比如where子句等呢

数据集

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack) 
    {
        DataSet dss = CalendarSpotting();
        Session["Calendar"] = dss;
    }
}

protected void Calndar_SelectionChanged(object sender, EventArgs e)
{
    DataSet ds = (DataSet)Session["Calendar"];
}
我喜欢做的是:

DataTable theTable=dataSet.Tables[0]

或:

DataTable theTable=dataSet.Tables[YourTableName]

这使得在我的文档中循环列和行变得更加容易 经验。像这样:

if(theTable.Rows[0]["YourColumnName"].toString() == "Itsmee")
{
 // do this, do that

}