Posts

Showing posts from 2013

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.  

DataTable clone c#

        public DataTable createData() {             DataTable dt = new DataTable();             DataRow dr;             dt.Columns.Add("ID", typeof(string));             dt.Columns.Add("First Name", typeof(string));             dt.Columns.Add("Last Name", typeof(string));             for (int i = 0; i < 30; i++)             {                 dr = dt.NewRow();                 dr[0] = "id_" + i.ToString();    ...

ajax call

 OnSubmitData="Store1_Submit"         var submitValue = function (grid, hiddenFormat, format, hiddenFormat1, format1 ) {             hiddenFormat.setValue(format);             grid.submitData(false, { isUpload: true });         };                             string format = this.FormatType.Value.ToString();

html to Excel

        public void button_click_Excel(object sender, EventArgs e) {             Response.Clear();             Response.ClearHeaders();             Response.ClearContent();             Response.ContentType = "application/force-download";             Response.AddHeader("content-disposition", "attachment; filename=Print.xls");             Response.Write(" ");             Response.Write(" ");             Response.Write("");             Response.Write(" ");             Response.Write(this.htmlData());             Response.Write(" ");            Response.Flush();         } ...

for get data with the variable c#

json = X.GetCmp ("Hidden1").Value.ToString();

pass extra parameter into the renderer FN

and the function will be:     var saveData = function (Hidden, GrPanel) {         //console.log(Ext.getCmp(param));         var gr = Ext.getCmp(Hidden);         Ext.getCmp(Hidden).setValue(Ext.encode(App.gr.getRowsValues({ selectedOnly: false })));     };

string to double c#

double number ; string value = "1,097.63" ; NumberStyles style = NumberStyles . Number | NumberStyles . AllowCurrencySymbol ; CultureInfo culture = CultureInfo . CreateSpecificCulture ( "en-US" ); if ( Double . TryParse ( value , style , culture , out number )) Console . WriteLine ( "Converted '{0}' to {1}." , value , number ); else Console . WriteLine ( "Unable to convert '{0}'." , value );

Two dimensional Array into DataTable

string   [,] mdArray = new string   [ 3 , 3 ]{{ "a" , "b" , "c" },{ "d" , "e" , "f" },{ "g" , "h" , "i" }};         ArrayList arList = new ArrayList ();         DataTable table = new DataTable ();        table . Columns . Add ( "C1" );        table . Columns . Add ( "C2" );        table . Columns . Add ( "C3" );         //Multi Dimension Array into DataTable         for ( int outerIndex = 0 ; outerIndex < 3 ; outerIndex ++)         {               DataRow newRow = table . NewRow ();             for ( int innerIndex = 0 ; innerIndex < 3 ; innerIndex ++)             {                newRow [ innerIndex ] = mdArray [ outerIndex , innerIndex...