C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




to subhi


Posted Date: 05 Jul 2008      Total Responses: 1

Posted By: Rameese       Member Level: Bronze     Points: 1



Hi subhi

i want Numerical Paging in Repeater using sql.

i wrote the sql stored procedure for getting row count,maximam rows,sort column,sort type.

how to integrate with repeater?

plzzzz very urgent





Responses

Author: Rathi    05 Jul 2008Member Level: GoldRating:     Points: 6

hai rameese

pls change this code in repeater

i give the code in datalist

sing System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
private DataTable dt = new DataTable();
private int pages = 0;
private int CurrentPageIndex = 0;
private int NewsPageSize = 5;
private int DiscontinuedProduct = 0;
private int ResultRowsFound = 0;
private int NavigationSize = 10;
bool _showBottomPager = true;


protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ProcessQueryString();
}
}

protected void BindGrid(DataTable dt)
{
if (dt.Rows.Count > 0)
{

dlProducts.DataSource = dt;
dlProducts.DataBind();

int rowsFound = Convert.ToInt32(dt.Rows[0]["ResultRowCount"]);
pages = rowsFound / NewsPageSize;
int thisPage = CurrentPageIndex;
ResultRowsFound = pages;

BindPager();

RowsFound.Text = string.Format("<b>Result Found : {0}</b>", rowsFound);

}
else
{
dlProducts.DataSource = null;
dlProducts.DataBind();

RowsFound.Text = "No Result found.";
}

}

private void GetProductsType()
{
switch (DiscontinuedProduct)
{
case 0:
GetProducts();
break;
case 1:
GetDiscontinuedProducts();
break;
default:
GetProducts();
break;
}
}

protected void Products_Click(object sender, EventArgs e)
{
GetLatest();
}

private void GetLatest()
{
ResetPageIndex();
DiscontinuedProduct = 0;
GetProducts();
}

private void GetProducts()
{
bool discontinued = false;
lblType.Text = "Products";
DataRetrieve dal = new DataRetrieve();
dal.GetProductByCategory(CurrentPageIndex, NewsPageSize, discontinued, dt);
BindGrid(dt);
}

protected void DiscontinuedProducts_Click(object sender, EventArgs e)
{
ResetPageIndex();
DiscontinuedProduct = 1;

GetDiscontinuedProducts();
}

private void GetDiscontinuedProducts()
{
bool discontinued = true;
lblType.Text = "Discontinued Products";
DataRetrieve dal = new DataRetrieve();
dal.GetProductByCategory(CurrentPageIndex, NewsPageSize, discontinued, dt);
BindGrid(dt);
}

private void ResetPageIndex()
{
CurrentPageIndex = 0;
}

private void ProcessQueryString()
{
if (Request.QueryString["pageidx"] != null)
{
CurrentPageIndex = int.Parse(Request.QueryString["pageidx"]);
}
else
{
CurrentPageIndex = 0;
}

if (Request.QueryString["pDiscontinued"] != null)
{
DiscontinuedProduct = int.Parse(Request.QueryString["pDiscontinued"]);
}
else
{
DiscontinuedProduct = 0;
}

GetProductsType();


}

private void BindPager()
{
if (pages < 1)
{
pnlPager.Visible = false;
return;
}

pnlPager.Visible = true;

bool showFirstPageLink;
bool showLastPageLink;
bool showStartElipticalLink;
bool showEndElipticalLink;
int startIdx = 0;
int endIdx = NavigationSize;
if (pages > NavigationSize && CurrentPageIndex > NavigationSize - 2)
{
endIdx = CurrentPageIndex + 1;
startIdx = endIdx - NewsPageSize + 1;

if (endIdx > pages)
{
endIdx = pages;
}
if (startIdx <= 0)
{
startIdx = 0;
}
}

if (endIdx > pages)
{
endIdx = pages;
}

showStartElipticalLink = showFirstPageLink = (startIdx > 1);
showEndElipticalLink = showLastPageLink = (endIdx < pages);

if (showFirstPageLink)
{
if (_showBottomPager)
{
AddPagerLink(this.pnlPager, 0, "<< First", "<< First", true, false, false);
}
}

if (showStartElipticalLink)
{
if (_showBottomPager)
{
AddPagerLink(this.pnlPager, startIdx - 1, "..", "Previous Page", true, true, false);
}
}

for (int i = startIdx; i <= endIdx; i++)
{
HyperLink bottomLink = new HyperLink();
LiteralControl bottomLiteral = new LiteralControl(" ");

if (CurrentPageIndex != i)
{
bottomLink.Text = (i + 1).ToString();
bottomLink.NavigateUrl = String.Format("~/Default.aspx?pageidx={0}&pDiscontinued={1}", i, DiscontinuedProduct);
}
else
{
bottomLink.Text = "<B>[" + (i + 1).ToString() + "]</B>";
}

pnlPager.Controls.Add(bottomLink);
pnlPager.Controls.Add(bottomLiteral);
}

if (showEndElipticalLink)
{
if (_showBottomPager)
{
AddPagerLink(this.pnlPager, endIdx + 1, "..", "Next Page", true, true, false);
}
}

if (showLastPageLink)
{
if (_showBottomPager)
{
AddPagerLink(this.pnlPager, pages, "Last >>", "Last >>", true, true, false);
}
}
}

private void AddPagerLink(Panel ctlPanel, int pageIdx, string strText, string strToolTip, bool setNavigationUrl, bool addLeadingSpace, bool addTrailingSpace)
{
if (addLeadingSpace)
{
AddSpacer(ctlPanel);
}

HyperLink pageLink = new HyperLink();
pageLink.Text = strText;
if (setNavigationUrl)
{
pageLink.NavigateUrl = String.Format("~/Default.aspx?pageidx={0}&pDiscontinued={1}", pageIdx, DiscontinuedProduct);
if (null != strToolTip)
{
pageLink.ToolTip = " .. ";
}
ctlPanel.Controls.Add(pageLink);
}

if (addTrailingSpace)
{
AddSpacer(ctlPanel);
}
}

private void AddSpacer(Control ctl)
{
LiteralControl lit = new LiteralControl();
lit.Text = " ";
ctl.Controls.Add(lit);
}
}




Default.aspx
Post Reply
You must Sign In to post a response.
Next : to ratheesh
Previous : SQL reporting server page setup - margin coding
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use