Posts

Showing posts from 2015

Convert DataTabel to Json in Asp.net

 Convert DataTabel to Json in Asp.net protected void Page_Load( object sender, EventArgs e)     {         DataTable dt = DtTable();         string change = ReturnJSON (dt);             } public DataTable DtTable()     {         DataTable table = new DataTable () { TableName = "Customer" };         DataColumn keyColumn = table.Columns.Add( "Id" , typeof (System. Int32 ));         table.Columns.Add( "Name" , typeof (System. String ));         table.Columns.Add( "Address" , typeof (System. String ));         table.PrimaryKey = new DataColumn [] { keyColumn };         table.Rows.Add( ...

Call .Cs method on .Aspx Page

Call  .Cs method on .Aspx Page Step 1: Method on  .Cs page    public string GetFileName()         {             return "kandy" ;         } Step 2: Calling from .aspx Page     < script >         $(document).ready( function () {                        var Filename = ' <% = GetFileName() %> ' ;             debugger ;             alert(Filename);         });     </ script >

Convert DataTable to Xml and Vice-Versa

Convert DataTable to Xml and Vice-Versa     protected void Page_Load( object sender, EventArgs e)     {         DataTable dt = DtTable();         string change = ConvertDatatableToXML(dt);         DataTable dtret = ConvertXMLtoDataTable(change);     }         public string ConvertDatatableToXML( DataTable dt)     {         MemoryStream str = new MemoryStream ();         dt.WriteXml(str, true );         str.Seek(0, SeekOrigin .Begin);         StreamReader sr = new StreamReader (str);         string xmlstr;         xmlstr = sr.ReadToEnd(); ...