473,385 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

In a GridView how do you search for an item and set the GridView1.PageIndex accordingly?

S_K
Hi,

I have a GridView that displays multiple pages.

I also have a TextBox where the user can input an ID (one of the
GridView column values).

I would like to use this TextBox.Text value to search the GridView for
that ID and set the
GridView.PageIndex so that this value is contained in the new page
that's now displayed.

There must be an easy way of doing this! Any ideas?

Thanks in advance.
Steve

Oct 18 '07 #1
1 6825
On Oct 18, 5:48 pm, S_K <steve_kers...@yahoo.comwrote:
Hi,

I have a GridView that displays multiple pages.

I also have a TextBox where the user can input an ID (one of the
GridView column values).

I would like to use this TextBox.Text value to search the GridView for
that ID and set the
GridView.PageIndex so that this value is contained in the new page
that's now displayed.

There must be an easy way of doing this! Any ideas?

Thanks in advance.
Steve

Hi Steve

you can do something like this

-----------------------------------------------

Protected Sub BindGrid()

Dim dr As Data.DataSet = ...

Dim dv As New DataView()
dv = dr.Tables(0).DefaultView

If TextBox.Text.Length 0 Then

Dim i As Integer = dv.Find(tbSearch.Text)

If i >= 0 Then
GridView.CurrentPageIndex = i \ GridView.PageSize
GridView.SelectedIndex = i
Else
GridView.SelectedIndex = 0
End If

....

Oct 18 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: | last post by:
Hello, I have a GridView in my ASP.NET 2.0 application that performs the paging feature perfect when I have it bound to a data source. But now I have it bound to a dataset and the paging...
10
by: NH | last post by:
I have a girdview with paging enabled. How can I add a message in the footer to say "Viewing records 1-15 of 45" etc Thanks
3
by: Thirsty Traveler | last post by:
I have a gridview where the datasource is bound after a selection. The result of doing this is that sorting and paging do not work. I was given a sample of how to resolve this, however my attempt...
8
by: AG | last post by:
ASP.NET 2.0, VS 2005 I have a gridview with paging enabled, bound to an objectdatasource. Both were dropped on to the page and configured via the wizards. Basically working as expected. The...
5
by: Andrew Robinson | last post by:
I am attempting to better automate a Pager Template within a GridView. I am succesfully skinning a Drop Down List withing my control (the DDL is added to my control). I correctly populate the item...
12
by: Cindy Lee | last post by:
When I do a sorta on 1 table, then the other table goes back to the original order. What can I set so, it keeps the order of the other current gridview's order. I set all the gridview values...
4
by: yehey2010 | last post by:
Hi, I have problem with my ASP.Net Code, I used GridView with Edit/Update on it. However the program seems not work correctly because it doesn't Update the OLD VALUE with the NEW VALUE. Please...
4
by: snowrupa | last post by:
my .cs file is using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using...
1
by: castron | last post by:
Hello All, I have a grid view that allows sorting, paging, editing, etc. Under On Load event, if I check: if(!IsPostBack){ DisplayData(); }, the Edit portion works fine. However, the Sorting...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...

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.