Posts

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();