Posts

outputType in c#

        public class ReturnType         {             public object Data;             public string OutputType;         } return new ReturnType() { Data = Result, OutputType = this.outputType }; public PivotTable.ReturnType get_report(string type, string perOAbso, string slatype, DataGrid datagrid, string tableId) { }

Move DataRow c#

        public void MoveDataRowTo(DataRow dataRow, int destination)         {             DataTable parentTable = dataRow.Table;             int rowIndex = parentTable.Rows.IndexOf(dataRow);             if (rowIndex > 0)             {                 DataRow newDataRow = parentTable.NewRow();                 for (int index = 0; index < dataRow.ItemArray.Length; index++)                     newDataRow[index] = dataRow[index];                 parentTable.Rows.Remove(dataRow);                 parentTable.Rows.InsertAt(newDataRow, destination);                 dataRo...

add list item into foreach loop

 Dictionary colsetup = new Dictionary (); foreach(System.Data.DataColumn colname in this.pivotData.Columns) {   list.Add(new Dictionary (colsetup));  }

Create Grid from database and databable ext.net

Databse Function:: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data.SqlClient; using System.Configuration; using System.Data; using System.Diagnostics; namespace iterna {     public static class Utils     {         public static void Log(string text)         {             System.Diagnostics.Debug.WriteLine(" " + text);         }     }     public class DbCon     {         private SqlConnection con = null;         private string sqlConnStr = "";         private ConnectionState connectionState = ConnectionState.Closed;         ///         ///          ///         public DbCon()         {     ...

date Format check c#

string [] format = new string []{ "yyyy-MM-dd HH:mm:ss" }; string value = "2011-09-02 15:30:20" ; DateTime datetime ; if ( DateTime . TryParseExact ( value , format , System . Globalization . CultureInfo . InvariantCulture , System . Globalization . DateTimeStyles . NoCurrentDateDefault , out datetime )) Console . WriteLine ( "Valid : " + datetime ); else Console . WriteLine ( "Invalid" );

specific date time format convert c#

 var dt = DateTime.Parse("2010-11-25");  string output = dt.ToString(@"yyyy-MMM", System.Globalization.CultureInfo.InvariantCulture);  content =  output ;

Best way Excel Export

the use of hyperlink instead of button is easier to export Excel from the back-end. because in button need the ajax request. and it is cumbersome to produce file with Ajax request.