473,763 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

In a GridView how do you search for an item and set the GridView1.PageI ndex 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.PageIn dex 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 6842
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.PageIn dex 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).De faultView

If TextBox.Text.Le ngth 0 Then

Dim i As Integer = dv.Find(tbSearc h.Text)

If i >= 0 Then
GridView.Curren tPageIndex = i \ GridView.PageSi ze
GridView.Select edIndex = i
Else
GridView.Select edIndex = 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
16345
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 feature will not work. When I try to use paging I get this error: The GridView 'gvResults' fired event PageIndexChanging which wasn't handled.
10
5309
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
6946
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 to explicity enable sorting failes because, unlike the sample, my sort event has a null in the datasource and I am unsure why this is so. Sample HTML code is: <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"...
8
8535
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 gridview's databind method is apparently called when the page is loaded as I have no code calling the databind method. How can I keep the gridview from databinding automatically and control it myself?
5
3006
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 list that corresponds with the number of pages, but I am unable to wire up the Selected Index Changed event. Auto PostBack is set to true and the page is posting back when the DDL is selected / chaged, but the event is never being called. Any...
12
3814
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 in my 'onpageload' in the cs file.
4
2256
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 help on this. thanks so much <%@ Page Language="C#" Debug="true" MasterPageFile="MasterPage.Master" Title="Untitled Page" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.Odbc" %> <script runat="server">
4
3511
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 System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls;
1
1158
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 and paging portions won't. If I just call the DisplayData() method then the Edit portion doesn't work. I found out that when sorting the sorting value doesn't persist and I need to store it elsewhere when doing postbacks, but the code below is already...
0
9563
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10145
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9938
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9822
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8822
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7366
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5270
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3523
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.