Search Results:

Saturday, July 16, 2016

Simple Code to get First Day of Week and Last Day of Week

I wanted a simple and quick way to get the start of week and end of week to do some data processing for the week. Here is a simple three line code that can help achieve this.

        DateTime dt  = DateTime.Now();
        DateTime FirstDayofWeek = dt.AddDays(-(int)dt.DayOfWeek);
        DateTime LastDayofWeek = FirstDayofWeek.AddDays(6);

Hope it helps, Thanks!!!

Thursday, July 14, 2016

Get PageNames in SSRS for SubReports.


I was recently presented with a situation where i need to place chart on one sheet and data in other sheet when exported to excel in SSRS. I tried to use page break after the chart and inserted a sub report.

When i did that, i noticed that that page names cannot be set for sub reports. In order to acheive something like below. I looked at work arounds to make the page names as shown in below image.


I noticed that the PageName property is available one tablix and rectangles. So i just placed a rectangle and set its PageName as "Other Custom Name 1" and then insert the subreport within this rectangle control and then the exported excel sheet hast the custom names as expected.



Let me know if you  have any other work arounds or if you found this post helpful.

Thank you.

Tuesday, July 5, 2016

Difference between a KeyPress and KeyDown Events

The KeyDown event triggers for all the keys where as KeyPress only works for the character keys.

For example:

If you press Key A, then it will fire KeyDown as well as KeyPress event.

If you press Shift,Ctrl, Escape or BackSpace keys then only KeyDown is the only


Refer:MSDN Link

Thursday, June 16, 2016

Filter datatable using LINQ in VB.NET

Below is a simple LINQ that you can use to filter the DataTable.


AsEnumerable() method to return the input type DataTable as IEnumerable.

CopyToDataTable() method takes the results of the filtered query and copies into a new DataTable that you can use to work with the filtered data.

-------------------------------------------------------------------------
         Dim filteredTable As DataTable = (From n In dt.AsEnumerable()
                                           Where n.Field(Of Int32)("id") = 1
                                           Select n).CopyToDataTable()
-------------------------------------------------------------------------

Feel free to leave your comments or suggestions. Thank you.