如何判断gridview里某一行的值是否在datatable中
string ConnString = "";
SqlConnection srcConnection = new SqlConnection();
SqlCommand sqloldbranch = new SqlCommand();
SqlDataAdapter daoldbranch = new SqlDataAdapter();
DataTable dtoldbranch = new DataTable();
ConnString = ConfigurationManager.ConnectionStrings["connstr"].ToString();
srcConnection.ConnectionString = ConnString;
sqloldbranch.Connection = srcConnection;
sqloldbranch.CommandText = "select 商场代码,商场名称 from test";
sqloldbranch.CommandType = CommandType.Text;
sqloldbranch.Connection.Open();
daoldbranch.SelectCommand = sqloldbranch;
daoldbranch.Fill(dtoldbranch);
sqloldbranch.Connection.Close();
// for (int j = 0; j < dtoldbranch.Rows.Count; j++)
// {
// string branchnum = dtoldbranch.Rows[i].ToString();
// }
for (int i = 0; i < GVBranch.Rows.Count; i++)
{
CheckBox cbox = (CheckBox)GVBranch.Rows[i].FindControl("CheckBox1");
if (GVBranch.Rows[i].Cells[1].Text.Trim().ToString() == "XXX")//怎么把dtoldbranch里的值放在这里进行判断呢?dtoldbranch里的值不止一行 {
cbox.Checked = true;
}
}
------解决方案--------------------
把dgv那行值取出来
用dt.Rows.Contains(dgv)来判断