Find row in datatable with specific id

前端 未结 8 1778
醉酒成梦
醉酒成梦 2020-12-05 00:07

I have two columns in a datatable:

ID, Calls. 

How do I find what the value of Calls is where ID = 5?

5 could be anynu

8条回答
  •  感情败类
    2020-12-05 00:29

    I could use the following code. Thanks everyone.

    int intID = 5;
    DataTable Dt = MyFuctions.GetData();
    Dt.PrimaryKey = new DataColumn[] { Dt.Columns["ID"] };
    DataRow Drw = Dt.Rows.Find(intID);
    if (Drw != null) Dt.Rows.Remove(Drw);
    

提交回复
热议问题