473,549 Members | 3,099 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

enable paging to a custom membership gridview

JustRun
127 New Member
Hi,

This is the first time to work with ASP.NET.
I had a customized membership gridview, the problem is i can't enable paging feature or sorting.


1 protected DataSet MyGetAllUsers()
2 {
3 DataSet ds = new DataSet();
4
5 dt = ds.Tables.Add(" Users");
6 muc = Membership.GetA llUsers();
7
8 dt.Columns.Add( "UserName", Type.GetType("S ystem.String")) ;
9 dt.Columns.Add( "Email", Type.GetType("S ystem.String")) ;
10 dt.Columns.Add( "CreationDa te", Type.GetType("S ystem.DateTime" ));
11 dt.Columns.Add( "IsOnline", Type.GetType("S ystem.Boolean") );
12 dt.Columns.Add( "IsLockedOu t", Type.GetType("S ystem.Boolean") );
13
14 foreach (MembershipUser mu in muc)
15 {
16 DataRow dr;
17 dr = dt.NewRow();
18 dr["UserName"] = mu.UserName;
19 dr["Email"] = mu.Email;
20 dr["CreationDa te"] = mu.CreationDate ;
21 dr["IsOnline"] = mu.IsOnline;
22 dr["IsLockedOu t"] = mu.IsLockedOut;
23
24 dt.Rows.Add(dr) ;
25 }
26 return ds;
27 }
28
29 protected void btnShowAll_Clic k(object sender, System.EventArg s e)
30 {
31 grdUsers.Visibl e = true;
32 MyGetAllUsers() ;
33 grdUsers.DataSo urce = dt;
34 grdUsers.DataBi nd();
35 }

This code is working so good, I've tried to put the following code to enable paging and sorting, it didn't fire any error But also it didn't give me any result:

private string ConvertSortDire ctionToSql(Sort Direction sortDireciton)
{
string newSortDirectio n = String.Empty;

switch (sortDireciton)
{
case SortDirection.A scending:
newSortDirectio n = "ASC";
break;

case SortDirection.D escending:
newSortDirectio n = "DESC";
break;
}

return newSortDirectio n;
}

protected void grdUsers_PageIn dexChanging(obj ect sender, GridViewPageEve ntArgs e)
{
grdUsers.PageIn dex = e.NewPageIndex;
grdUsers.DataBi nd();
}

protected void grdUsers_Sortin g(object sender, GridViewSortEve ntArgs e)
{
DataTable dataTable = grdUsers.DataSo urce as DataTable;

if (dataTable != null)
{
DataView dataView = new DataView(dataTa ble);
dataView.Sort = e.SortExpressio n + " " + ConvertSortDire ctionToSql(e.So rtDirection);

grdUsers.DataSo urce = dataView;
grdUsers.DataBi nd();
}
}



Any ideas?
Apr 9 '08 #1
0 1139

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1133
by: Wiktor Zychla [C# MVP] | last post by:
Hello, just two sad thoughts on GridView's custom paging support, the first one rather general and second one rather specific. First one: I really miss the DataGrid custom paging support with AllowCustomPaging and VirtualCount. The new declarative model with ObjectDataSource is much worse! - the amount of "words" you have to type is...
3
2182
by: Marc Grutte | last post by:
Hi I am trying to bind a custom datasource to a gridview whilst paging is enabled. What is missing in this code to make the paging + binding work? thanks M <%@ Page Language="VB" %>
3
3733
by: Ronald S. Cook | last post by:
I was told that if calling lots of records from the database (let's say 100,000), that the GridView's paging feature would automatically "handle" everything. But the 100,000 records are still coming to the client, right? I mean, the paging feature isn't somehow making calls to the database for 25 records at a time or anything like that...
7
2318
by: =?Utf-8?B?SmVmZiBCZWVt?= | last post by:
The default paging behavior of the gridview doesn't work well with very large sets of data which means we have to implement some sort of custom paging. The examples I have seen (4guysfromrolla, etc.) suggest using an ObjectDataSource which has built-in paging functionality that, when used in conjunction with certain SQL 2005 functionality,...
1
2669
by: John Mott | last post by:
Hi All, I recently read a post that said that google and other spiders are unable to navigate paging in the GridView control because it uses postbacks and it can't determine the url. I've verified that it doesn't see portions of my site that are on page 2 and beyond according to whats generated. This is not a good thing if your want...
5
5123
by: =?Utf-8?B?Z3V5?= | last post by:
How do you enable editing in a GridView programatically rather than via its Tasks menu? Guy
1
1942
by: John A Grandy | last post by:
In regard to a GridView that must support searching, filtering, sorting, and paging ... There is a tradeoff in performing the sorting and paging in the database versus to creating a CLR sort expression and allowing the GridView to perform the sorting and paging. How do people feel about each option for (1) simple sorts (alphabetical,...
6
2137
by: cmrchs | last post by:
Hello, I have set the Allowpaging property to true in a standard DataGrid- control (System.Web.UI.WebControls). when run in the browser i get the first records in the first page, there are 5 pagesi n total, but when I click on the next page number, I always get the records of the first page ? how come?
1
4597
by: Danny Ni | last post by:
Hi, Could someone point me to source sample C# code to do gridview custom paging? No ObjectDataSource please, the reason I don't want to use ODS is the page is already created using the DataSource to do data binding, it will takes some efforts to convert it to use ODS. TIA
0
7520
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7718
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7470
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6041
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1058
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.