Tuesday, 10 January 2012

working with local reports rdlc files from a dataset

created a local reports (rdlc) - which takes heading as a parameters.
data also comes dynamically through a datatable.
 
DataTable dtPrint = (DataTable)Session["Table"];  // data to be bound can be from session or viewstate
string rptHeading = Request.QueryString["heading"];   // heading
rpvPrint.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
rpvPrint.LocalReport.ReportPath = Page.MapPath(".") +  "\\Report.rdlc";
ReportParameter[] rp =new ReportParameter[1];
rp[0] = new ReportParameter("Heading", rptHeading);
rpvPrint.LocalReport.SetParameters(rp);  
ReportDataSource rds1 = new ReportDataSource("PrintData", dtPrint);
rpvPrint.LocalReport.DataSources.Clear();   
rpvPrint.LocalReport.DataSources.Add(rds1);
rpvPrint.LocalReport.Refresh();

regular expressions for datetime dd/MM/yyyy , MM/dd/yyyy, MM-DD-YYYY and DD-MM-YYYY

Regex DD/MM/YYYY Format

(((0[1-9]|[12][0-9]|3[01])([/]
)(0[13578]|10|12)([/])(\d{4}))|(([0][1-9]|[12][0-9]|30)([/])(0[469]|11)([/])(\d{4}))|((0[1-9]|1[0-9]|2[0-8])([/])(02)([/])(\d{4}))|((29)([/])(02)([/])([02468][048]00))|((29)([/])(02)([/])([13579][26]00))|((29)([/])(02)([/])([0-9][0-9][0][48]))|((29)([/])(02)([/])([0-9][0-9][2468][048]))|((29)([/])(02)([/])([0-9][0-9][13579][26 ])))

Regex MM/DD/YYYY Format

(((0[13578]|10|12)([/])(0[1-9]|[12][0-9]|3[01])([/])(\d{4}))|((0[469]|11)([/])([0][1-9]|[12][0-9]|30)([/])(\d{4}))|((02)([/])(0[1-9]|1[0-9]|2[0-8])([/])(\d{4}))|((02)([/])(29)([/])([02468][048]00))|((02)([/])(29)([/])([13579][26]00))|((02)([/])(29)([/])([0-9][0-9][0][48]))|((02)([/])(29)([/])([0-9][0-9][2468][048]))|((02)([/])(29)([/])([0-9][0-9][13579][26 ])))


Regex DD-MM-YYYY Format

(((0[1-9]|[12][0-9]|3[01])([-])(0[13578]|10|12)([-])(\d{4}))|(([0][1-9]|[12][0-9]|30)([-])(0[469]|11)([-])(\d{4}))|((0[1-9]|1[0-9]|2[0-8])([-])(02)([-])(\d{4}))|((29)([-])(02)([-])([02468][048]00))|((29)([-])(02)([-])([13579][26]00))|((29)([-])(02)([-])([0-9][0-9][0][48]))|((29)([-])(02)([-])([0-9][0-9][2468][048]))|((29)([-])(02)([-])([0-9][0-9][13579][26 ])))

Regex MM-DD-YYYY Format

(((0[13578]|10|12)([-])(0[1-9]|[12][0-9]|3[01])([-])(\d{4}))|((0[469]|11)([-])([0][1-9]|[12][0-9]|30)([-])(\d{4}))|((02)([-])(0[1-9]|1[0-9]|2[0-8])([-])(\d{4}))|((02)([-])(29)([-])([02468][048]00))|((02)([-])(29)([-])([13579][26]00))|((02)([-])(29)([-])([0-9][0-9][0][48]))|((02)([-])(29)([-])([0-9][0-9][2468][048]))|((02)([-])(29)([-])([0-9][0-9][13579][26 ])))

click event does not work / trigger/fire, click event triggers/fires in double click

when working on click event in javascript or jquery, click won't fire the event 
in a single click. it requires double click. in that case 
your code may look like the following
 
<ul id="drop-menu" style="display:none;">
<li><a href="..">xxxx xxxx</a> </li>
<li><a href="..">** *** *** **</a> </li>
<li><a href="..">... ... .. </a> </li>
<li><a href="LogOff">Log Off</a> </li>
</ul>
 
 $("a#my-link").click(function(e) {
$("#drop-menu").slideToggle('medium');
});
$("body").click(function(e) {
$("#drop-menu").hide();
}); 
 
in reality, click event fires / triggers the click event, however along with the 
click event body click event also fires thus hiding your drop-menu.
here we cannot stop body click event, removing which our drop-menu doesnot get 
closed. to stop closing or hiding of our drop-menu on body click, 
we have to check the target of the event
 
like the one in the following code
$("a#my-link").click(function(e) {
$("#drop-menu").slideToggle('medium');
});
$("body").click(function(e) {
if (!$(e.target).is('#my-link')) {
$("#drop-menu").hide();
}
});
 
here in body click i am hiding the drop menu, only when the target of the click
event is my-link.
 

how to stop skype from formatting phone numbers on your webpage

include this, to stop skype from formatting the phone numbers on your webpage
<meta name="SKYPE_TOOLBAR" content="SKYPE_TOOLBAR_PARSER_COMPATIBLE" />

implementing sql "in" in linq to sql

using (DataContext dc = new DataContext("connectionstring"))

   {

     List<string> names = new List<string>();

    names.Add("Anderson");

    names.Add("Johnson");

    List<Person> list = (from p in dc.GetTable<Person>() where names.Contains(p.LastName) select p).ToList();

  }

equivalent Sql generated by the above is

DECLARE @p1 NVarChar(8);

DECLARE @p0 NVarChar(7);

Select @p1 = 'Johnson';

Select @p0 = 'Anderson';

-- Context: SqlProvider(Sql2005) Model: AttributedMetaModel Build: 3.5.21022.8

SELECT [t0].[Id], [t0].[FirstName], [t0].[LastName]

FROM [dbo].[Person] AS [t0]

WHERE [t0].[LastName] IN (@p0, @p1)

this is found in googling, don't remember url

javascript decimal point precision

 rounding of a decimal value and decimal place of 1
 parseFloat(val).toFixed(1);

will give 0.563583 as 0.6.