DataTable has a Select method. This method receives a string expression that specifies what rows you want to handle. Selection based on a string expression DataRow[] result = table.Select("Size >= 230 AND Sex = 'm'"); Selection based on DateTime DataRow[] result = table.Select("Date > #6/1/2001#"); Number of records for a particular criteria int numberOfRecords = […]
Sometimes it is required to remove last character usually a comma from SQL string, below are 3 way to achieve it. Option 1: Using LEFT function DECLARE @String as VARCHAR(50) SET @String='1,2,3,4,5,' SELECT @String As [String] ,LEFT(@String,LEN(@String)-1) As [Last Character removed from string] GO Option 2: Using STUFF function DECLARE @String as VARCHAR(50) SET @String='1,2,3,4,5,' […]
C# DataTable to a HTML Table Below is C# function to generate HTML table string from DataTable with custom options like Custom headers and Selected fields. “Format” in parameters will contain comma separated values like column1=column 1 name, column2=column 2 name and so on. public static string DataTableToHtmlTable(DataTable TableData, string Format) { try { Dictionary<string, […]
C# DataTable to a CSV file C# DataTable to a CSV file with default options i.e. all columns with default column names public static string DataTableToCsvFile(DataTable TableData, string FileName) { try { // change this with any delimiter you want string Delimiter = ","; int i = 0; StreamWriter sw = null; sw = new […]
Definition and Usage The CONVERT() function is a general function that converts an expression of one data type to another. The CONVERT() function can be used to display date/time data in different formats. Syntax CONVERT(data_type(length),expression,style) Value Description data_type(length) Specifies the target data type (with an optional length) expression Specifies the value to be converted style […]
Formatting ASP.net GridView BoundField For Date and Time DataFormatString="{0:d-MMM-yyyy}" For Decimals DataFormatString="{0:F2}" For Currency DataFormatString="{0:C2}" For Percentage DataFormatString="{0:P2}"
Context Menu (even in full screen) Ctrl + Right Click CTRL Key Bound Ctrl + a - Jump to the start of the line Ctrl + b - Move back a char Ctrl + c - Terminate the command Ctrl + d - Delete from under the cursor Ctrl + e - Jump to the […]
Rounding off to 2 decimal places cast(round([value],2) as decimal(18,2)) Compare only Year from datetime field select * from [table_name] where year(date_time_field) = year(getdate()) check if a SQL server string is null or empty ISNULL(NULLIF(text, ''), '') AS Offer_Text The differences between LEN and DATALENGTH in SQL Server LEN Returns the number of characters, rather than […]
Adding text to a span using jquery $("#spanid").text("Your text here"); Adding html to a span using jquery $("#spanid").text("HTML here"); Append html to a span using jquery $("#spanid").append("HTML here"); Check/uncheck a checkbox input or radio button $("#x").prop("checked", true); $("#x").prop("checked", false); Check checkbox checked property $("#x").is(':checked') Handle change of checkbox $('#x').change(function() { if($(this).is(":checked")) { //'checked' event code […]
Most modern browsers include Developer tools which helps developers analyze client html and scripts. To write something from Javascript to console below options are available. Error gives you the red error message console.error(message); Default gives the default message console.log(message); Warning gives the warning message with the exclamation mark in front of it console.warn(message); Information gives […]