Going to a specific page?

G

gerry

My client would like a alphabetic lookup bar to allow navigation to a
specific page of a datagrid - the page which has the first occurance of
the "key" field that starts with the clicked on letter. For example, if
the user clicks on "E-H" the datagrid will present the page which
contains the first occurance of an item which starts with E, F, G or H.
The alpha lookup bar supplements the existing next page/previous page
links.

My approach - brute force - is to sort the dataset alphabetically, find
the first row that meets the lookup criteria, calculate the page index
based on the row #, and then set the Datagrid.currentPageIndex to the
calculated page index. Does this seem like a reasonable approach? Is
there an easier method?
 
M

Mohamed Sharaf

Hi Gerry,
I think you can use another approach which could save you a lot of
server resources. This approach based on SQL statement that get you the
specific record set you want.

For example, if you are using the customers table in Northwind database.
The select statement would be

Select * from customers where ContactName like '[e-h]%'

Does it sound appropriate for your case?

Best regards,
Mohamed Sharaf
MEA Developer Support Center
ITWorx on behalf Microsoft EMEA GTSC
--------------------
| From: "gerry" <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| Subject: Going to a specific page?
| Date: 26 Sep 2005 07:44:44 -0700
| Organization: http://groups.google.com
| Lines: 14
| Message-ID: <[email protected]>
| NNTP-Posting-Host: 24.54.208.186
| Mime-Version: 1.0
| Content-Type: text/plain; charset="iso-8859-1"
| X-Trace: posting.google.com 1127745889 18670 127.0.0.1 (26 Sep 2005
14:44:49 GMT)
| X-Complaints-To: (e-mail address removed)
| NNTP-Posting-Date: Mon, 26 Sep 2005 14:44:49 +0000 (UTC)
| User-Agent: G2/0.2
| X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;
.NET CLR 1.0.3705; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe)
| Complaints-To: (e-mail address removed)
| Injection-Info: g44g2000cwa.googlegroups.com; posting-host=24.54.208.186;
| posting-account=lttQ5AwAAADmzfHluUSfdlzz7GIIb_wi
| Path:
TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onli
ne.de!border2.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!g4
4g2000cwa.googlegroups.com!not-for-mail
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet.datagridcontrol:5635
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
|
| My client would like a alphabetic lookup bar to allow navigation to a
| specific page of a datagrid - the page which has the first occurance of
| the "key" field that starts with the clicked on letter. For example, if
| the user clicks on "E-H" the datagrid will present the page which
| contains the first occurance of an item which starts with E, F, G or H.
| The alpha lookup bar supplements the existing next page/previous page
| links.
|
| My approach - brute force - is to sort the dataset alphabetically, find
| the first row that meets the lookup criteria, calculate the page index
| based on the row #, and then set the Datagrid.currentPageIndex to the
| calculated page index. Does this seem like a reasonable approach? Is
| there an easier method?
|
|
 
G

gerry

Thanks Mohamed!

Your suggestion is ideal. Unfortunately, the application doesn't have a
rationale data access layer - SQL is interspersed with presentation
code and business logic. I've taken a approach which is a variant of
your suggestion - defining a rowfilter on the dataview prior to binding
to the grid. Performance is not an issue. There are only a few hundred
records in the DB with anticipated growth of 10-20 records per year.

As an aside I'm taking the dataview filter approach for expediancy. A
supposedly senior developer who was also PM on the project with no
oversight created a monstrosity of an app - he's now gone. Since we've
already screwed the client the few $s left are being applied to meeting
the clients specific requirements while fixing the unseen
application/coding errors on our $. The last and biggest hurdle is to
build stored procedures for the primary datagrid. When I build the
stored procedures I'll add an option to constrain the search by alpha
range.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top