Newest Post

Showing posts with label Database. Show all posts
Showing posts with label Database. Show all posts

Code to export the Grid View/Data Grid data into Excel File.

| Friday, February 13, 2015
Read more »
 protected void btnExportToExcel_Click(object sender, EventArgs e)  
       DataTable dt = student.GetDetails("B.Tech").Tables[0];  
       DataGrid GridView1 = new DataGrid();  
       GridView1.DataSource = dt;  
       Response.Buffer = true;  
       Response.AddHeader("content-disposition", string.Format("attachment; filename=StudentsBTech.xls"));  
       Response.Charset = "";  
       Response.ContentType = "application/";  
       StringWriter sw = new StringWriter();  
       HtmlTextWriter htw = new HtmlTextWriter(sw);  
       GridView1.GridLines = GridLines.Both;  
       GridView1.AllowPaging = false;  
     catch (Exception ex)  
     finally { Response.End(); }  
   public override void VerifyRenderingInServerForm(Control control)  
   { }  

Could not add reference to "System.Net.Http.Formatting" namespace in WPF web api client project

| Friday, December 12, 2014
Read more »
For adding the reference in your web api client

1. Right click on "References" in the solution.
2. Following window will open.

3. Select location "Extension" as shown above and check "System.Net.Http.Formatting" namespace
4. and DONE!!!

Convert DataSet or DataTable into JSON in C#

| Tuesday, June 10, 2014
Read more »
 public string ConvertToJSON(DataSet ds)  
 System.Web.Script.Serialization.JavaScriptSerializer serializer = 
new System.Web.Script.Serialization.JavaScriptSerializer();  
     List<Dictionary<string, object>> rows = 

new List<Dictionary<string, object>>();  
     Dictionary<string, object> row = null;  
     foreach (DataRow dr in ds.Tables[0].Rows)  
       row = new Dictionary<string, object>();  
       foreach (DataColumn col in ds.Tables[0].Columns)  
         row.Add(col.ColumnName.Trim(), dr[col]);  
     return serializer.Serialize(rows);  

Convert DataSet or DataTable into JSON in C#

Posted by : Pooja
Date :Tuesday, June 10, 2014
With 0comments