i want to update datatable
(dtTaskandBugs) on some condition.
want to update storyid of all the row in the datatable when the id(which is a column of the Datatable) is passed as paramter to the function
GetStoryid. this is my code below it's not working (nothing happening)
dtTaskandBugs.Select(string.Format("Storyid = '{0}'", dtTaskandBugs.Rows)).ToList<DataRow>().ForEach(
r =>
{
r["Storyid"] = GetStoryid(r["Id"]);
});
The error is here:
string.Format("Storyid = '{0}'", dtTaskandBugs.Rows)
You are passing the number of rows in this table as argument to DataTable.Select
which filters the rows, so probably doesn't return any rows.
I suggest a simple foreach
-loop since you want to update all rows:
foreach(DataRow row in dtTaskandBugs.Rows)
row ["Storyid"] = GetStoryid(row["Id"]);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.