Skip to content

Tying up loose ends

September 20, 2012

So another day has come and gone!And busying typing up loose ends on the reports on the .rdlc files. A tip is to allow yourself to reuse the files as much as possible, well if not the .rdlc files then the .aspx files which link them as associating which .aspx.cs file links wiith which .rdlc file is a bit of a nightmare.

Anyways, I had managed to link the toggle button which I had added earlier on the reports page with the session data being populated into the DataTable which is used by the report definition file (.rdlc) that generates the report.


System.Globalization.CultureInfo provider = System.Globalization.CultureInfo.InvariantCulture;
provider = new System.Globalization.CultureInfo(“en-US”);

string latestDateString = portalSessions.Month + “/” + portalSessions.Day + “/” + portalSessions.Year;

DateTime value;
DateTime latestDate;
if (DateTime.TryParseExact(latestDateString, “M/d/yyyy”, CultureInfo.InvariantCulture, DateTimeStyles.None, out value))
latestDate = Convert.ToDateTime(latestDateString, provider);
latestDate = DateTime.Today;

if (newUserList.Contains(latestDate))
int result = newUserList.FindIndex(delegate(DateTime d)
return d == latestDate;

if (result != -1)
object[] userObject = (object[])newUserCountList[result];

row[“NewUserrCount”] = userObject[0].ToString();

row[“NewUserCount”] = 0;

catch (Exception ex)


On the outside of the method at the global declaration I added: –

ArrayList newUserCountList;

List<DateTime> newUserList = new List<DateTime>();


All this code (with a bit of research) essentially checks on my newUserCountList containing days, months, and year data of a count of new users registering to the website, it only containscounts of greater than zero and does a compare with this useful method .Contains on Lists. I was going to do it the hard way comparing with each value and looping through two lists (don’t do that!) but realised that is a lot of computing power and unnecessary checks hence saving time. The List operations in this case is a lot easier!! The DataTable gets updated with the relevent row that has new users registered on that date!

The other way I thought about doing was to this: –

// Get last 2 elements reversed
	var last = list.Reverse<string>().Take(2);

But this stores it in the rather un-useful var!!

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: