Thursday, 24 May 2012

Sending an E-mail using Asp.Net | c#.net example

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Xml.Linq;
using System.Text;
using System.Web.Mail;
using System.IO;
using System.Net;

public partial class Mail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
         string strHtml = this.GetHTML("http://www.domain-name.com/ack-mail.aspx"); // Mailer Form
         
         const string SERVER = "Your Mail Server Address"; // Your Mail Server Address
         MailMessage oMail = new System.Web.Mail.MailMessage();
         oMail.From = "xxxx@gmail.com";
         oMail.To = "xxxx@gmail.com";
         oMail.Cc = "xxxx@gmail.com,xxxx@gmail.com";
         oMail.Subject = "Subject";
         oMail.BodyFormat = MailFormat.Html; // enumeration
         oMail.Priority = MailPriority.High; // enumeration
         oMail.Body = strHtml;
         SmtpMail.SmtpServer = SERVER;
         SmtpMail.Send(oMail);
         oMail = null; // free up resources
    }
    public string GetHTML(string strURL)
    {
         HttpWebRequest wbrq = (HttpWebRequest)WebRequest.Create(strURL);
         wbrq.Method = "GET";
         HttpWebResponse wbrs = (HttpWebResponse)wbrq.GetResponse();
         StreamReader sr = new StreamReader(wbrs.GetResponseStream());
         string strResult;
         strResult = sr.ReadToEnd();
         sr.Close();
         return strResult;
    }
}

Saturday, 12 May 2012

Dynamic url rewriting in asp.net | c#.net example

Step 1
First we have to add the following files in Website Bin folder...
Intelligencia.UrlRewriter.dll
Intelligencia.UrlRewriter.dll.refresh
Intelligencia.UrlRewriter.xml


Step 2
web.config

<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config

-->
<configuration>
<configSections>
<section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter"/>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
<appSettings/>
<connectionStrings>
<add name="sqlconnstr" connectionString="Data Source=xxxxxxxx;Initial Catalog=xxxx;User ID=xxxxx;Password=xxxxxx" providerName="SQLOLEDB.1"/>
</connectionStrings>
<system.web>
<httpModules>
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpModules>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.

-->
<compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.

-->
<authorization>
<allow users="*"/>
</authorization>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.

<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>

-->
<customErrors mode="Off"/>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
</pages>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpHandlers>
</system.web>
<rewriter>
<rewrite url="~/(.+)/(.+)/result.aspx" to="~/dynamic-url/focus.aspx?search=$1&amp;sid=$2"/>
</rewriter>

<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="OptionInfer" value="true"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<remove name="ScriptModule"/>
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<remove name="ScriptHandlerFactory"/>
<remove name="ScriptHandlerFactoryAppServices"/>
<remove name="ScriptResource"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

Step 3
dynamic-url.aspx

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Xml.Linq;
using System.Text;

public partial class dynamic_url : System.Web.UI.Page
{
    public string str;
    protected void Page_Load(object sender, EventArgs e)
    {
         string myString = "Sakthi, Shunmuga Thangam, Iyyappan @ Kathir, Mari Mani Kandan, etc..";
         
         char[] separator = new char[] { ',' };
         string[] strList = myString.Split(separator);
         int i;
         str += "<table><tr><td width='15%' align=center></td><td style='font-size:13px;'>";
         
         for (i = 0; i <= strList.GetUpperBound(0); i++)
         {
               if (i == 0)
                   str += "<i><font color='#FF00FF' size='2px'><a href='" + GenerateURL(strList[i].Trim(),i) + "'>" + strList[i].Trim() + "</a>,</font></i> ";
               else
                   str += "<i><font color='#FF00FF' size='2px'><a href='" + GenerateURL(strList[i].Trim(),i) + "'>" + strList[i].Trim() + "</a>,</font></i> ";
         }
         
         str += "</td></tr></table>";
         Response.Write(str);
         
    }
    public static string GenerateURL(object Title, object Id)
    {
         string strTitle = Title.ToString();
         string strid = Id.ToString();
         #region Generate SEO Friendly URL based on Title
         //Trim Start and End Spaces.
         strTitle = strTitle.Trim();
         //Trim "-" Hyphen
         strTitle = strTitle.Trim('-');
         strTitle = strTitle.ToLower();
         char[] chars = @"$%#@!*?;:~`+=()[]{}|\'<>,/^&"".".ToCharArray();
         strTitle = strTitle.Replace("c#", "C-Sharp");
         strTitle = strTitle.Replace("vb.net", "VB-Net");
         strTitle = strTitle.Replace("asp.net", "Asp-Net");
         //Replace . with - hyphen
         strTitle = strTitle.Replace(".", "-");
         //Replace Special-Characters
         for (int i = 0; i < chars.Length; i++)
         {
              string strChar = chars.GetValue(i).ToString();
              if (strTitle.Contains(strChar))
              {
                   strTitle = strTitle.Replace(strChar, string.Empty);
              }
         }
         //Replace all spaces with one "-" hyphen
         strTitle = strTitle.Replace(" ", "-");
         //Replace multiple "-" hyphen with single "-" hyphen.
         strTitle = strTitle.Replace("--", "-");
         strTitle = strTitle.Replace("---", "-");
         strTitle = strTitle.Replace("----", "-");
         strTitle = strTitle.Replace("-----", "-");
         strTitle = strTitle.Replace("----", "-");
         strTitle = strTitle.Replace("---", "-");
         strTitle = strTitle.Replace("--", "-");
         //Run the code again...
         //Trim Start and End Spaces.
         strTitle = strTitle.Trim();
         //Trim "-" Hyphen
         strTitle = strTitle.Trim('-');
         #endregion
         //Append ID at the end of SEO Friendly URL
         strTitle = "" + strTitle + "/" + strid + "/result.aspx";
         return strTitle;
    }
}

Step 4

<rewriter>
<rewrite url="~/(.+)/(.+)/result.aspx" to="~/dynamic-url/focus.aspx?search=$1&amp;sid=$2"/>
</rewriter>

we must create a page focus.aspx inside the dynamic-url folder, ,
In this focus.aspx page we can get two query string values...
Now we can show the focus.aspx with different url.....

Output

Sakthi,
Shunmuga Thangam,
Iyyappan @ Kathir,
Mari Mani Kandan,
etc..,

Friday, 11 May 2012

Delete a row from google spreadsheet | c#.net example


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Xml.Linq;
using System.Text;
using Google.GData.Client;
using Google.GData.Spreadsheets;

public partial class View_Gdata : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
         string strsid = Request.QueryString["sid"];
         
         SpreadsheetsService service = new SpreadsheetsService("exampleCo-exampleApp-1");
         service.setUserCredentials("xxxx@gmail.com", "xxxx");
         
         SpreadsheetQuery query = new SpreadsheetQuery();
         query.Title = "Spreadsheet Name";
         SpreadsheetFeed feed = service.Query(query);
         
         if (feed.Entries.Count == 0)
         {
               // TODO: There were no spreadsheets, act accordingly.
         }
         
         SpreadsheetEntry spreadsheet = (SpreadsheetEntry)feed.Entries[0];
         WorksheetFeed wsFeed = spreadsheet.Worksheets;
         WorksheetEntry worksheet = (WorksheetEntry)wsFeed.Entries[0];
         AtomLink listFeedLink = worksheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);
         ListQuery listQuery = new ListQuery(listFeedLink.HRef.ToString());
         listQuery.SpreadsheetQuery = "sid=" + strsid + "";//This will select a perticular row for delete... strsid is a string, it contains the number.
         ListFeed listFeed = service.Query(listQuery);
         
         ListEntry row = (ListEntry)listFeed.Entries[0];
         
         row.Delete();
    }
}

Tuesday, 8 May 2012

Update a row in google spreadsheet | c#.net example


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Xml.Linq;
using System.Text;
using Google.GData.Client;
using Google.GData.Spreadsheets;

public partial class View_Gdata : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
         SpreadsheetsService service = new SpreadsheetsService("exampleCo-exampleApp-1");
         service.setUserCredentials("xxxx@gmail.com", "xxxx");
         
         SpreadsheetQuery query = new SpreadsheetQuery();
         query.Title = "Spreadsheet Name";
         SpreadsheetFeed feed = service.Query(query);
         
         if (feed.Entries.Count == 0)
         {
               // TODO: There were no spreadsheets, act accordingly.
         }
         
         SpreadsheetEntry spreadsheet = (SpreadsheetEntry)feed.Entries[0];
         WorksheetFeed wsFeed = spreadsheet.Worksheets;
         WorksheetEntry worksheet = (WorksheetEntry)wsFeed.Entries[0];
         AtomLink listFeedLink = worksheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);
         ListQuery listQuery = new ListQuery(listFeedLink.HRef.ToString());
         listQuery.SpreadsheetQuery = "sid=" + lblId.Text + "";//This will select a perticular row for updating... lblId is a label it contains the number
         ListFeed listFeed = service.Query(listQuery);
         
         ListEntry row = (ListEntry)listFeed.Entries[0];
         // Update the row's data.
         foreach (ListEntry.Custom element in row.Elements)
         {
               if (element.LocalName == "sname")
               {
                     element.Value = txtSName.Text;
               }
               if (element.LocalName == "snumber")
               {
                     element.Value = txtSNumber.Text;
               }
               if (element.LocalName == "sarea")
               {
                     element.Value = txtSArea.Text;
               }
         }
         // Save the row using the API.
         row.Update();
    }
}

Monday, 30 April 2012

Adding a new row in Google Spreadsheet | c#.net example

using System ;
using Google . GData . Client ;
using Google . GData.Spreadsheets;

public partial class Add_Gdata : System.Web.UI.Page
{
 
protected void Page_Load(object sender, EventArgs e)
 
{
   

   

     
SpreadsheetsService service = new SpreadsheetsService("exampleCo-exampleApp-1");

     
// TODO: Authorize the service object for a specific user (see other sections)

     
service.setUserCredentials("xxxxxxxxxx@gmail.com", "xxxxxxxxxx");
     
SpreadsheetQuery query = new SpreadsheetQuery();

     
query.Title = "Name of the Spreadsheet xxxx";
     
SpreadsheetFeed feed = service.Query(query);

     
if (feed.Entries.Count == 0)
     
{
       
// TODO: There were no spreadsheets, act accordingly.
     
}

     
// TODO: Choose a spreadsheet more intelligently based on your
     
// app's needs.
     
SpreadsheetEntry spreadsheet = (SpreadsheetEntry)feed.Entries[0];
     
//Response.Write(spreadsheet.Title.Text);

     
// Get the first worksheet of the first spreadsheet.
     
// TODO: Choose a worksheet more intelligently based on your
     
// app's needs.
     
WorksheetFeed wsFeed = spreadsheet.Worksheets;
     
WorksheetEntry worksheet = (WorksheetEntry)wsFeed.Entries[0];

     
// Define the URL to request the list feed of the worksheet.
     
AtomLink listFeedLink = worksheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);

     
// Fetch the list feed of the worksheet.
     
ListQuery listQuery = new ListQuery(listFeedLink.HRef.ToString());
     
ListFeed listFeed = service.Query(listQuery);

     
ListEntry existingRow = (ListEntry)listFeed.Entries.First();
      ListEntry newRow = new ListEntry();

      string[] values = new string[] { "str1", "str2", "str3" };"

      int count = 0;

      foreach (ListEntry.Custom element in existingRow.Elements)

      {

           ListEntry.Custom curElement = new ListEntry.Custom();

           curElement.LocalName = element.LocalName;

           curElement.Value = values[count];

           newRow.Elements.Add(curElement);

           count++;

      }


     
// Send the new row to the API for insertion.
      ListEntry insertedRow = listFeed.Insert(newRow) as ListEntry;

   

 
}
}

Monday, 16 April 2012

Google Spreadsheets API
Google Spreadsheets API Complete Lesson
C#.net Example
Google spreadsheet into a DataTable using GData
View_Gdata.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
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.Xml.Linq;
using System.Web.Mail;
using System.IO;
using System.Net;
using System.Xml;
using System.Collections.Specialized;
using System.Text;
using Google.GData.Client;
using Google.GData.Spreadsheets;

public partial class View_Gdata : System.Web.UI.Page
{
    public double CurrPage, pageLen, lastNumber, PageRem, PageTen, next10, prev10, nPageCount, pnPageCount, start, RSPrevPage, RSNextPage, P;
    public string sSQL = null, strsession = null;
    public int countchk;
    protected void Page_Load(object sender, EventArgs e)
    {
         SpreadsheetsService service = new SpreadsheetsService("exampleCo-exampleApp-1");
         service.setUserCredentials("xxxx@gmail.com", "xxxx");
         
         SpreadsheetQuery query = new SpreadsheetQuery();
         query.Title = "Spreadsheet Name";
         SpreadsheetFeed feed = service.Query(query);
         
         if (feed.Entries.Count == 0)
         {
               // TODO: There were no spreadsheets, act accordingly.
         }
         
         SpreadsheetEntry spreadsheet = (SpreadsheetEntry)feed.Entries[0];
         WorksheetFeed wsFeed = spreadsheet.Worksheets;
         WorksheetEntry worksheet = (WorksheetEntry)wsFeed.Entries[0];
         AtomLink listFeedLink = worksheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);
         ListQuery listQuery = new ListQuery(listFeedLink.HRef.ToString());
         ListFeed listFeed = service.Query(listQuery);
         
         PagedDataSource pds = new PagedDataSource();
         var table = new DataTable();
         
         foreach (ListEntry row in listFeed.Entries.Reverse())
         {
               var roww = table.NewRow();
               foreach (ListEntry.Custom element in row.Elements)
               {
                     var column = table.Columns[element.LocalName] ?? table.Columns.Add(element.LocalName);
                     roww[column] = element.Value;
               }
               table.Rows.Add(roww);
         }
         
         pds.DataSource = table.DefaultView;
         
         pds.AllowPaging = true;
         pds.PageSize = 30;
         if (Request.QueryString["page"] != null)
         {
               CurrPage = Convert.ToInt32(Request.QueryString["page"].ToString());
               int intPage = (Convert.ToInt32(Request.QueryString["page"]) - 1);
              if (intPage < 0) intPage = 0;
              if (intPage > pds.PageCount) intPage = pds.PageCount - 1;
               pds.CurrentPageIndex = intPage;
        }
         else
         {
                CurrPage = 1;
         }
         
         next10 = Convert.ToDouble(getNext10(CurrPage));
         prev10 = Convert.ToDouble(getPrev10(CurrPage));
         nPageCount = pds.PageCount;
         pnPageCount = Convert.ToInt32(nPageCount) - 1;
         
         rptr.DataSource = pds;
         rptr.DataSource = pds;
         
         RSPrevPage = CurrPage - 1;
         RSNextPage = CurrPage + 1;
         
         if (next10 > pds.PageCount)
         {
                next10 = pds.PageCount;
         }
         
         if (prev10 == 1 & next10 - 1 < 10)
         {
                start = 1;
         }
         else
         {
                start = next10 - 10;
                if (Convert.ToInt32(start.ToString().Substring(start.ToString().Length - 1, 1)) > 0)
                {
                      start = Convert.ToDouble(start.ToString().Replace(start.ToString().Substring(start.ToString().Length - 1, 1), "0"));
                      start = start + 10;
                }
         }
         
         MyLiteral.Text = CreatePagerLinks(pds, next10, prev10, "View_Gdata.aspx");
    }
    public static string CreatePagerLinks(PagedDataSource pds, double next10, double prev10, string BaseUrl)
    {
         StringBuilder sbPager = new StringBuilder();
         sbPager.Append("<div class='paginationTTIQ'><p>");
         if (!pds.IsFirstPage)
         {
               // first page link
               sbPager.Append("<a href=\"");
               sbPager.Append(BaseUrl);
               sbPager.Append("\">|<</a> ");
               sbPager.Append("<a href=\"View_Gdata.aspx?page=" + prev10 + "\"><<</a> ");
               if (pds.CurrentPageIndex != 1)
               {
                     // previous page link
                     sbPager.Append("<a href=\"");
                     sbPager.Append(BaseUrl);
                     sbPager.Append("?page=");
                     sbPager.Append(pds.CurrentPageIndex.ToString());
                     sbPager.Append("\" alt=\"Previous Page\"><</a> ");
               }
          }
          // calc low and high limits for numeric links
          int intLow = pds.CurrentPageIndex - 1;
          int intHigh = pds.CurrentPageIndex + 3;
          if (intLow < 1) intLow = 1;
          if (intHigh > pds.PageCount) intHigh = pds.PageCount;
          if (intHigh - intLow < 10) while ((intHigh < intLow + 9) && intHigh < pds.PageCount) intHigh++;
          if (intHigh - intLow < 10) while ((intLow > intHigh - 9) && intLow > 1) intLow--;
          for (int x = intLow; x < intHigh + 1; x++)
          {
               // numeric links
               if (x == pds.CurrentPageIndex + 1) sbPager.Append(x.ToString() + " ");
               else
               {
                     sbPager.Append("<a href=\"");
                     sbPager.Append(BaseUrl);
                     sbPager.Append("?page=");
                     sbPager.Append(x.ToString());
                     sbPager.Append("\">");
                     sbPager.Append(x.ToString());
                     sbPager.Append("</a> ");
               }
          }
          if (!pds.IsLastPage)
          {
               if ((pds.CurrentPageIndex + 2) != pds.PageCount)
               {
                     // next page link
                     sbPager.Append("<a href=\"");
                     sbPager.Append(BaseUrl);
                     sbPager.Append("?page=");
                     sbPager.Append(Convert.ToString(pds.CurrentPageIndex + 2));
                     sbPager.Append("\">></a> ");
               }
               if (!(next10 == pds.PageCount))
               {
                     sbPager.Append("<a href=\"View_Gdata.aspx?page=" + next10 + "\">>></a>");
               }
               // last page link
               sbPager.Append("<a href=\"");
               sbPager.Append(BaseUrl);
               sbPager.Append("?page=");
               sbPager.Append(pds.PageCount.ToString());
               sbPager.Append("\"<<|</a>");
          }
          sbPager.Append("</p></div>");
          // conver the final links to a string and assign to labels
          return sbPager.ToString();
     }
     public object getNext10(double num)
     {
           pageLen = num.ToString().Length;
           if (pageLen == 1)
           {
                 next10 = 10;
           }
           else if (pageLen > 1)
           {
                 PageRem = 10;
                 PageTen = Convert.ToInt32(num.ToString().Substring(num.ToString().Length - 1, 1));
                 next10 = num + PageRem - PageTen;
           }
           return next10;
     }
     public object getPrev10(double num)
     {
           pageLen = num.ToString().Length;
           if (pageLen == 1)
           {
                 prev10 = 1;
           }
           else if (pageLen > 1)
           {
                 lastNumber = Convert.ToInt32(num.ToString().Substring(num.ToString().Length - 1, 1));
                 prev10 = num - lastNumber - 10;
           }
           if (prev10 == 0)
           {
                 prev10 = 1;
           }
           return prev10;
     }
     public static string Right(string param, int length)
     {
           string result = param.Substring(param.Length - length, length);
           return result;
     }
     public int PageNumber
     {
           get
           {
                 if (ViewState["PageNumber"] != null)
                       return Convert.ToInt32(ViewState["PageNumber"]);
                 else
                       return 0;
           }
           set
           {
                 ViewState["PageNumber"] = value;
           }
     }
}

View_Gdata.aspx
<%@ Page Language="C#" MasterPageFile="MasterPage.master" AutoEventWireup="true" CodeFile="View_Gdata.aspx.cs" Inherits="View_Gdata" Title="View Gdata" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:Label ID="MyLiteral" Runat="server" ></asp:Label>
<div>
<br />
<asp:Repeater ID="rptr" Runat="server">
<HeaderTemplate>
<table>
<thead>
<tr>
<th>Enquiry ID</th>
<th>Name</th>
<th>Moblie</th>
<th>Area</th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%#Eval("sid").ToString()%></td>
<td><%#Eval("sname").ToString()%> </td>
<td><%#Eval("snumber").ToString()%></td>
<td><%#Eval("sarea").ToString()%></td>
</tr>
</ItemTemplate>
<footertemplate>
</tbody>
</table>
</footertemplate>
</asp:Repeater>
</div>
</asp:Content>