code for Custom paging without using sqldatasource control and sql datasource control for gridview...........

 code for Custom paging without using sqldatasource control and sql datasource control for gridview...........

i need code for how to show all pagenumbers in gridview with custom paging in gridview..............

It is very urgent................................. 


T.Ashok Kumar
0
ashokt4
9/17/2008 8:19:39 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

2 Replies
1357 Views

Similar Articles

[PageSpeed] 29

 suppose that we have a table like this

CountryId  identity int

CountryTitle    nvarchar(50)

you can use this sql command for paging the data

USE [CyberOffice]
GO
/****** Object:  StoredProcedure [dbo].[CountryGetListPaged]    Script Date: 09/17/2008 14:01:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[CountryGetListPaged]
    @PageSize int,
    @pageNumber int,
    @TotalPageCount int out
    @OrderBy VARCHAR(100) = NULL,
    @OrderByDirection VARCHAR(20) = 'D'
AS
SET @OrderBy = COALESCE(@OrderBy,'CountryTitle')
SET @OrderByDirection = COALESCE(@OrderByDirection,'D')
IF LEN(@OrderByDirection) > 1  SET @OrderByDirection = UPPER(LEFT(@OrderByDirection,1))
Declare @recordCount int
Declare @StartId int
Declare @EndId int

SET TRANSACTION ISOLATION LEVEL READ COMMITTED
SELECT @recordCount = Count(*) FROM [Country] 
IF (@PageSize <= 0)
    SELECT @PageSize = 20
SELECT @TotalPageCount = @recordCount / @PageSize + 1
IF (@pageNumber > @TotalPageCount)
    SELECT @pageNumber = 1
SELECT @StartId = (@PageNumber - 1) * @PageSize + 1
SELECT @EndId = @StartId + @PageSize -1

;
WITH PagedTable AS
(SELECT ROW_NUMBER() OVER (
 ORDER BY
CASE WHEN @OrderBy = 'CountryId' AND @OrderByDirection = 'D' THEN HelpTable.[CountryId] END DESC,CASE WHEN @OrderBy = 'CountryId' AND @OrderByDirection != 'D' THEN HelpTable.[CountryId] END,
CASE WHEN @OrderBy = 'CountryTitle' AND @OrderByDirection = 'D' THEN HelpTable.[CountryTitle] END DESC,CASE WHEN @OrderBy = 'CountryTitle' AND @OrderByDirection != 'D' THEN HelpTable.[CountryTitle] END
 )AS RowNumber ,
     HelpTable.[CountryId],
    HelpTable.[CountryTitle]
FROM
     [dbo].[Country] HelpTable
 )
SELECT * FROM PagedTable WHERE RowNumber BETWEEN @StartId AND @EndId 
 ORDER BY
CASE WHEN @OrderBy = 'CountryId' AND @OrderByDirection = 'D' THEN PagedTable.[CountryId] END DESC,CASE WHEN @OrderBy = 'CountryId' AND @OrderByDirection != 'D' THEN PagedTable.[CountryId] END,
CASE WHEN @OrderBy = 'CountryTitle' AND @OrderByDirection = 'D' THEN PagedTable.[CountryTitle] END DESC,CASE WHEN @OrderBy = 'CountryTitle' AND @OrderByDirection != 'D' THEN PagedTable.[CountryTitle] END


 


سیستم آموزش مجازی
سیستم مدیریت کتابخانه دیجیتال
وستا
گزارش ساز
0
Mojtaabaa
9/17/2008 9:34:03 AM

Hi Ashok,

Refer to these links and implement

http://www.codeproject.com/KB/aspnet/custompaging.aspx,

http://weblogs.asp.net/alessandro/archive/2007/10/09/custom-serverside-paging-in-gridview-vs-datagrid.aspx.

 

Thanks,

Farooq


Mark as answer if this post helpfull to you.

Don't be afraid to be wrong; otherwise you'll never be right.
0
susain
9/17/2008 9:59:28 AM
Reply:

Similar Artilces:

Trying to use the FAQ " Sorting and paging in the GridView control when not using data source controls "Sorting and paging in the GridView control when not using..."
and I am not getting the results I had hoped for.  I keep getting a "Compiler Error Message: CS0123: No overload for 'AdhocJobGridView_PageIndexChanged' matches delegate 'System.EventHandler'".   Here is my event handling... protected void AdhocJobGridView_PageIndexChanged(object sender, GridViewPageEventArgs e){ try { AdhocJobGridView.DataSource = wsBaseInfoArray; AdhocJobGridView.PageIndex = e.NewPageIndex; AdhocJobGridView.DataBind(); }catch (Exception ex) {throw ex; }   Here is my aspx... <asp:GridView ID="AdhocJobGridView...

how can I delete a row from gridview in code-behind page without using sqldatasource control?
Hi, I have image button in my gridview. and I put its command name property 'delete'. could you please tell me what code should I have in my code behind page to delete row? I don't use sqldatasource for databound I use dataset. I use VB for coding. Thanks. Something like this: Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand If (e.CommandName.Equals("delete")) Then Dim btn As ImageButton = TryCast(e.CommandSource, ImageButton) If btn IsNot Nothing...

Custom Control within a Control Control
I am developing a custom controls that will render headers for different web sites. Within these controls, I want to place another custom control that will change the language. I created the language control and had it implement IPostBackDataHandler. This control works fine if I drag it on a new web form, but if I tell a header custom control to render it problems occur. The Language Selector custom control does not have a Page member anymore and the event handlers do not work. Does anyone have any experience with doing something similiar? Anyone have any suggestions? Thanks, ...

Custom Datasource Controls Vs. Object Datasource Controls
Hi folks,I am a web developer developing pages in the project. I need to integrate the front end pages with the backend API. Active directory is being used as the database system for our project. I only use the API and the methods offered by it to interact with the data.For all the operations on the data, I have methods that I can call from the API (viz. Create(), Delete(), Modify() etc.). For connecting the data to my frontend data controls (viz. GridView, DropDownList etc.) I can use Object Datasource Control. I also read some articles about Custom Datasource controls. Now, I am having a d...

Page and Control Flashing Using AJAX Control Toolkit Controls
Page and Control Flashing Using AJAX Control Toolkit Controls I'm using IE7 and the ASP.NET AJAX Control Toolkit.  I'm using two controls -- Accordion and CollapsiblePanelExtender.  I'm actually using 2 CollapsiblePanelExtenders, and the Accordion control is inside one of the panels for the CollapsiblePanelExtender (see the code below). The problem I'm seeing is that when I click an Accordion pane to open/close it or click the CollapsiblePanelExtender panel to open/close the panels, the controls and page flash while the animation is in progess.  Everything el...

Issue with getting values from child controls in a gridview, to use for the update using a SQLDataSource control
Hi all, I have a gridview bound with a SQLDataSource. I am using the Update feature of the SQLDataSource to update a SQL Server database with values entered into the gridview. However I am not getting it to work. I believe this is due to the controls that contain the user entries are not the gridview itself, but rather child controls within the gridview. I have been using the names of the actual controls but nothing happens. Upon submit, the screen returns blank, and the database is not updated. Here is some code:   <asp:GridView ID="GridEditSettlement" runat="server" AutoGenerate...

SqlDataSource Control and Gridview control
Hi, I'm new to web development and learning about these controls.  The books teach you to bind the gridview control to an sqldatasource to perform delete,update,insert functions as well as to list the records in a table.  Is this standard practice for real world applications?  Or is there another way that should be used to display/manage table data in the gridview control? Thanks. Tulsi Using a sqldatasource is the best way I know of for binding data to a gridview.  (I'm pretty new to web development too, so maybe someone else can chime in if they know someth...

using controlS to control a gridview
This question is probably posted but i did not bother to look at 10,000+ posts so i am sorry. I've seen the tutorial where he builds a dataset and uses a gridview and controls the gridview with the drop down list box. What i am trying to do is to control the gridview with 2 drop down list boxes. First select the Country you life in and then the State. I've looked at the grid view properties but couldn't find where i can add another parameter. Is it possible to control a grid view (or any form of displaying the information) with more than 1 controller? Thank You.  ...

ajax.net controls used in custom composite controls?
I am creating an events calendar that uses the accordion to display the events for the selected day.  The problem I'm having is that the accordion is not responding to any client side events.  I would really like to find a good "How to" article for building composite controls that incorporate an ajax.net control like the accordion....

How to access page property (or just controls in it) from a custom DataSource control
Hi, I am currently working on a number of various custom datasource controls. I've found the solution for most problems on the way so far, but now I really got stuck. One of my controls will take a set of various input parameters, similar to the good old SQLDataSource control. One of my parameter classes is supposed to take a value from an arbitrary control on the page. Howevere, it does not seem to be an easy way to access the Page property (from inside this control) on my DataSource control. I need this to use FindControl. When I do so, from inside my "Externa...

Control of the page and the controls on a page
I am building a web app that has some pages that are public and some that are only available based on subscription. Could someone explain the best way (infrastructure wise) how to control whether a server control is visible or enabledand how to control whether a page is viewable or not based on the user and whether or not the user is logged in (or not). If a user is not logged in I would like some controls to be visible but disabled. I also have to control the URL's in case a person learnsthe URL and tries to type it in. My question is more towards how to do this database wise. I am u...

What control do I use (or do I not use a control at all...)
Okay so here's the story so far. I am making a blog to be incorporated into a website. Well, I'm doing the blog from scratch. I'm using MySQL to source all the data via MySQL .NET/Connector. Now while developing the script, I used DataReader and Response.Write to show the blog topics. Now that it has come to put it under a design (I'm using a Master Page for that), I've hit the problem. Response.Write shows all the topics before any of the design elements could be incorporated. So that (more or less) is out of question. So next I looked into the data presentation controls. I looked up GridVi...

Using Data Controls Without Using ObjectDataSource Control
Hi, I've been looking on the Internet for a tutorial that would show me how to use the data conrols (FormView, GridView etc) without using an ObjectDataSource (or any other data source control).  The reason is that I want to use a formview and gridview from within another formview control to create a single form  that would allow me to insert, update and delete an order and its order details at the same time. I thought that this could be achieved by having a DataSet containing two DataTable objects in the code-behind with the Order DataTable containing one row to repres...

Using controls from pages, master pages, and user controls
How would I structure my site in this scenario: I'd like to use a dropdownlist all over my site, sometimes in a regular page, sometimes in a master page, and sometimes in a user control.  I wish to bind its events programmatically, so normally I would just put that in the codebehind.  However, I notice a lot of code duplication because I have to declare the control in everywhere, in my base page (which all my pages inherit from), in my base master page (which all my master pages inherit from) and in my base user control (which all my user controls inherit from).How should I be...

Web resources about - code for Custom paging without using sqldatasource control and sql datasource control for gridview........... - asp.net.presentation-controls

Top Ranked Articles
Top Ranked Articles - Free source code and tutorials for Software developers and Architects.; Updated: 23 Feb 2013

Using The LINQDataSource
-*+There is a new datasource control available in Visual Studio that works in much the same way as the SQLDataSource and the ObjectDataSource. ...

Gabriel Mongeon
Archive - Gabriel Mongeon

moredotnet
M ore d otnet .NET Interview Questions, ASP.NET, C#, VB.NET, XML, SQL Check Out http://www.dotnetUncle.com √ .NET NOTES OOPS in .NET .NET ...

Architectural Overview of the Windows Presentation Foundation Beta 1 Release
Introduction Windows Presentation Foundation Beta 1 Windows Integration New Features WinFX SDK Exploring the New Features Introducing "Express" ...

About Mikesdotnetting
I started this site as somewhere to store answers to bits and pieces that I see asked frequently in the forums at www.asp.net . Rather than type ...

Using MiniProfiler with SqlDataSource ASP.NET WebForms Control
public class ProfiledSqlDataSource : SqlDataSource{ protected override DbProviderFactory GetDbProviderFactory() { // get the "base" DbProviderFactory ...

ASP.NET Pivot Table - RadPivotGrid for ASP.NET AJAX
... reports. RadPivotGrid allows easy customization of all data reports. Try now! Use any declarative data source control (AccessDataSource, SqlDataSource, ...

Sign on
Sign On • Join • Forums Home User Name * Password * Remember me next time ( I forgot my password ) SUBMIT YOUR WTF Content Random Article All ...

ComboBox Sample
ComboBox is an ASP.NET AJAX control that, like the AutoCompleteExtender , combines the flexibility of a TextBox with a list of options that users ...

Resources last updated: 1/21/2016 8:23:44 AM