Monday, January 24, 2011

Row Count is always equal to page size when allow paging set to true.

This can be resolved by adding followings before call row count


Gridview1.AllowPaging=false;
GridView1.Datasource=yourdatasource;
Gridview1.DataBind();
//row count
GridView1.AllowPaging=true;
 

Friday, January 21, 2011

Formating issues in Html to Pdf using iTextSharp

When generating pdf documents Html to pdf using iTextSharp i have to face formatting issues. Here the solution.Use PDF Template

 You can use Adobe Acrobat professional to create a PDF form template.Put a TextFeild and give a name for that as text1.Then set the formattings.

In the c# code follow these steps

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.IO;
using System.Xml;
using System.Xml.Linq;
/* reference to the itextsharp */
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.Text;
namespace ItextSharpTut
{
  public class UtilityMethod
  {
    public void generatePDF()
    {
      try
      {
        string pdfTemplate = System.Web.HttpContext.Current.Server.MapPath("~/doc/new.pdf");
        PdfReader pdfReader = null;
        // Create the form filler
        FileStream pdfOutputFile = new FileStream(pdfTemplate, FileMode.Create);
        string path = System.Web.HttpContext.Current.Server.MapPath("~/doc/template.pdf");
        pdfReader = new PdfReader(path);
        PdfStamper pdfStamper = null;
        pdfStamper = new PdfStamper(pdfReader, pdfOutputFile);
        // Get the form fields
        AcroFields testForm = pdfStamper.AcroFields;
        testForm.SetField("text1", "Lasantha");
        PdfContentByte overContent = pdfStamper.GetOverContent(1);
        pdfStamper.FormFlattening = true;
        pdfStamper.Close();
        pdfReader.Close();
      }

 catch (Exception ex)
 {
   throw ex;
 }

}
}
} 

Enjoy it.

Learn more how amazing programing with itextsharp


Wednesday, January 19, 2011

Monday, January 17, 2011

Bind Both string and int value to a label


<asp:Label ID="lbltimezoneedit" runat="server" Text='<%#Eval("tzoperation")+Eval("tzhour").ToString()+"."+Eval("tzmin").ToString()%>' Visible="true">
</asp:Label>
 

TinyMCE Insert/Edit link not editable

 To fix this add  e.stopImmediatePropagation()  as below. $(document).on('focusin', function (e) {             if ($(e.target).close...