首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

关于DataTable的,好手来帮帮忙

2012-08-01 
关于DataTable的,高手来帮帮忙C# code AccountInfoBLL bll new AccountInfoBLL()DataTable dt bll.Get

关于DataTable的,高手来帮帮忙

C# code
 AccountInfoBLL bll = new AccountInfoBLL();        DataTable dt= bll.GetAccountById(id);        DataTable sdt = bll.BindStageDropDownList();        for (int i = 0; i < sdt.Rows.Count; i++)        {                    }


GetAccountById这个方法是根据Id得到一个数据表,BindStageDropDownList这个方法是绑定下拉列表框的数据表。我调用GetAccountById这个方法得到dt时,dt里面有个站点类型,我想要拿dt里的站点类型跟sdt这个里面的站点类型去比较,如果有就默认选中,代码怎么写啊

[解决办法]
C# code
AccountInfoBLL bll = new AccountInfoBLL();        DataTable dt= bll.GetAccountById(id);        DataTable sdt = bll.BindStageDropDownList();        for (int i = 0; i < sdt.Rows.Count; i++)        {            for(int j = 0; j < sdt.Rows.Count; j++)                            if(dt.Rows[i]["Type"].ToString()==sdt.Rows[i]["Type"])        }
[解决办法]
C# code
        for (int i = 0; i < sdt.Rows.Count; i++)        {            for (int j = 0; j < dt.Rows.Count; j++)            {              //这里比较吧,比如                      if (dt.Rows[j].Cells[0].Value.ToString() ==            sdt.Rows[i].Cells[0].Value.ToString())                      {                      //选中                      }             }        } 

热点排行