c# - Displaying course details later than today's date -


i'm using vsta c# on infopath 2010 form, whereby using cascading drop downs (course title & course details) information displayed.

so when user selects course title drop down, course details populated starttime, endtime, location , development category information sharepoint 2010 list.

now problem have want user view course details today , onwards, , not view course details past. code whereby display coursedetails. i've tried declaring datetime variable , using compare string converts datetime today, make later datetime variable, gives me error after select course title, says "object reference not set instance of object". troubleshooting tips: "use new keyword create object instance. check determine if object null before calling method. gengeral exception"

using (web = site.openweb())             {                 try                 {                     //spsecurity.runwithelevatedprivileges(new spsecurity.codetorunelevated(delegate()                     //{                     splist lstdocs = web.lists["training calander"] splist;                      string stitle = "";                     string ssdate = "";                     string sedate = "";                     string slocation = "";                     string sdcategory = "";                     string coursedetails = "";                     //datetime todaydate = datetime.today;                      //datetime dt1 = convert.todatetime(sedate);                         if (lstdocs != null)                      {                         sortedlist<string, string> lstdetails = new sortedlist<string, string>();                          foreach (splistitem item in lstdocs.items)                         {                             try                             {                                 stitle = item["title"].tostring();                                 ssdate = item["starttime"].tostring();                                 sedate = item["endtime"].tostring();                                 slocation = item["location"].tostring();                                 sdcategory = item["development category"].tostring();                                }                             catch { }                               if (stitle == nvalue) //&& (dt >= todaydate))                              {                                 try                                 {                                     coursedetails = ssdate + " - " + sedate + " | " + slocation + " | " + sdcategory;                                     lstdetails.add(coursedetails,coursedetails);                                   }                                 catch { }                             }                         } 

i believe problem best solved before execute foreach loop. need create query select items meet criteria using clause. can iterate through loop without having test date on each pass, going slower.

assuming startdate stored date variable, should trivial query write.

apologies if have misunderstood issue.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -