Jagjit Saini

Jagjit Saini

  • NA
  • 196
  • 37.6k

Searching Record in Datatable

Mar 16 2022 10:38 AM

Hi

 I have below code . In Dt0 there r 2 records . It is not going in query condition. There is same record in dt0 & dt

DataTable dt0 = new DataTable();
DataColumn dc1 = new DataColumn() { DataType = System.Type.GetType("System.String"), ColumnName = "ID" };
DataColumn dc2 = new DataColumn() { DataType = System.Type.GetType("System.String"), ColumnName = "Mobile" };

dt0.Columns.Add(dc1);
dt0.Columns.Add(dc2);

foreach (var element in Result)
{
    var row = dt0.NewRow();
    row["ID"] = element.ID;
    row["Mobile"] = element.Mobile;
    dt0.Rows.Add(row);
}

foreach (DataRow colum in dt.Rows)
{

    var query = from p in dt0.AsEnumerable()
                where p.Field<string>("Mobile") == colum[7].ToString()
                select new
                {
                    Mobile = p.Field<string>("Mobile"),
                };
}

Thanks


Answers (1)