Posts

Showing posts from August, 2016

Get DataKeyName value on rowcommand and rowdatabound event in asp.net

Simplest way to get Datakeyname Value  on rowcommand and rowdatabound event in asp.net < asp : GridView ID ="Grd" runat ="server   DataKeyNames ="rowid , Status , Sender , sscalltime"                                                 onrowcommand ="GridINfo_RowCommand"   onrowdatabound ="GridINfo_RowDataBound">                                             < Columns > < asp : TemplateField ItemStyle-Width ="120px" >               ...

Create PDF from HTML in asp.net

This is a simple article to generate pdf from html string. Just call the below code snippet .Here i am using  NReco.PdfGenerator.dll to generate pdf.  NmaeSpace using System.Text; using System.IO; using NReco; protected void Button4_Click( object sender, EventArgs e)     {         string PdfPath= "Pdf" + new Random ().Next().ToString();         var htmlContent = String .Format("Hello Test <b>PDF</b>" );  // html string come here         var htmlToPdf = new NReco.PdfGenerator. HtmlToPdfConverter ();         var pdfBytes = htmlToPdf.GeneratePdf(htmlContent);         FileStream file = File .Create(Server.MapPath( "~/PDF/" +PdfPath+ ".pdf" ));         file.Write(pdfBytes, 0, pdfBytes.Len...

Login with facebook in asp.net using C#

Name Space using System.Configuration; using System.Data.SqlClient; using System.Data; using Newtonsoft; using Newtonsoft.Json; using Newtonsoft.Json.Linq;     string appid = "" ;    string secretid = "" ;  // here replace " /Fb/Login.aspx"  with your redirect url page protected void Page_Load( object sender, EventArgs e)     {    HyperLink1.NavigateUrl = "https://www.facebook.com/v2.4/dialog/oauth/?client_id=" + appid + "&redirect_uri=http://" + Request.ServerVariables[ "SERVER_NAME" ] + ":" + Request.ServerVariables[ "SERVER_PORT" ] + "/Fb/Login.aspx&response_type=code&state=1" ;               if (Request.QueryString[ "code" ] != "" )         {             GetFacebookUserData(Request.QueryString[ "code" ]);  ...

SQL Optimization Techniques

SQL  Optimization Techniques: 1)  The sql query becomes faster if you use the actual columns names in SELECT statement instead of than '*'. For Example:  Write the query as SELECT id, first_name, last_name, age, subject FROM student_details; Instead of: SELECT * FROM student_details; 2)  HAVING clause is used to filter the rows after all the rows are selected. It is just like a filter. Do not use HAVING clause for any other purposes.  For Example:  Write the query as SELECT subject, count(subject)  FROM student_details  WHERE subject != 'Science'  AND subject != 'Maths'  GROUP BY subject; Instead of: SELECT subject, count(subject)  FROM student_details  GROUP BY subject  HAVING subject!= 'Vancouver' AND subject!= 'Toronto'; 3)  Sometimes you may have more than one subqueries in your main query. Try to minimize the number of subquery block in your query.  For Example:  Write the quer...