Find a Row in Datatable
I have a datatable with three columns (ItemID, ItemPrice, ItemDescription). I was trying to find a specific row (the item price of the supplied ItemID) based on ItemID supplied. I have the following code but it returns null all the time. Did i miss something here ?
DataTable dt = ds.Tables[0];
DataColumn[] dc = new DataColumn[1];
dc[0] = "ItemID"];
dt.PrimaryKey = dc;
DataRow dr = dt.Rows.Find(1); // 1 is the itemID
The problem is dr is always null.
any help would be appreciated.
|