Remove row from data table (hash table) C# vs2010
Posted on 2013-12-24
Background: I am working on an asp.net website (intranet) using c# that employs proprietary web methods to download students exam material from a hosted web site.
I have no control over what gets downloaded from a hosted site. I do have control over what is displayed. I am displaying an exam details page that opens from a link on a course page. The problem is the hosted site is not filtering out previous exam results (for same exam) which is bad for me. I am comparing dates and attempting to delete the older rows. My aim is to display only one exam.
I need help with the syntax to delete a row from a dataset, or I can select a row to publish to the databound fields on the html page. I feel the later might be harder than just deleting the row.
ds is the dataset downloaded from hosted website, and configured with xml stylesheet.
Column which compare is made: LessonStatusDate
if (lesson.Rows.Count > 1)
//Keep the most recent row
lessonCount = 0;
foreach (DataRow lessonRow in ds.Tables["Lesson"].Rows)
//C# complains if I don't assign a value. The property "Now" is not relevant to anything, it's just a value.
DateTime dt1 = DateTime.Now;
DateTime dt = Convert.ToDateTime(ds.Tables["Lesson"].Rows[lessonCount]["LessonStatusDate"]);
if (lessonCount == 0)
dt1 = dt.Date;
if ((lessonCount > 1) && (dt.Date > dt1.Date))
Thanks in advance for your help. ...and yes, some of us used up all our vacation days and are working on Christmas Eve. ;-(