Delete datasource row in web part SetupControl

Vaha C asked on October 25, 2018 11:53

I have custom web part, there is ucSitemap control (inherites GoogleSitemap). In SetupControl i assign properties to ucSiteMap and then call ucSiteMap.ReloadData(true) ... ucSiteMap.SiteName = SiteName; ucSiteMap.WhereCondition = WhereCondition; ucSiteMap.ReloadData(true);

after this i delete some rows from ucSiteMap.DataSource and call ucSiteMap.DataSource.AcceptChanges(); foreach (DataRow row in ucSiteMap.DataSource.Tables[0].Rows) { if (condition_here) { row.Delete(); } } ucSiteMap.DataSource.AcceptChanges();

but deleted records are still on the page. How can i delete records from ucSiteMap.DataSource and reflect these changes on the page?

Recent Answers


Peter Mogilnitski answered on October 25, 2018 12:50

looks like you are deleting the data after the binding. Did you try to reverse these pieces of code?

0 votesVote for this answer Mark as a Correct answer

Vaha C answered on October 25, 2018 13:50

Peter Mogilnitski what do you mean under "try to reverse these pieces of code"? I can't go through datasource until i load data to it.

0 votesVote for this answer Mark as a Correct answer

Zach Perry answered on October 25, 2018 17:10

Did you try reloading after you delete?

ucSiteMap.ReloadData(true);

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.