473,480 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ItemDataBound/CurrentPageIndex and DataGrids

I have a Web Server App which colors the row based on a selection from
a listbox (ie the data is expanded and highlighted on the grid from
the listbox).

This works OK except when the DataGrid has several pages, and then the
correct page is not shown (but the correct is still highlighted just
on a page not shown).

How can I set the right page index based on the selected row?

My Code:
DataGrid1_ItemDataBound(...)
if ((e.Item.ItemType==ListItemType.Item)
|| (e.Item.ItemType==ListItemType.AlternatingItem))
{
string thisPartNumber = lblPartNumber.Text;

string thisDBPartNumber =
DataBinder.Eval(e.Item.DataItem,"PartNumber").ToSt ring();

if (thisDBPartNumber == thisPartNumber)
{
e.Item.BackColor=System.Drawing.Color.Azure;
// I want to add the page index here and set the index somehow

}
else
{

e.Item.Attributes.Add("onmouseover","this.style.ba ckgroundColor='azure';");
e.Item.Attributes.Add("onmouseout","this.style.bac kgroundColor='white';");
}
Nov 11 '08 #1
0 972

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

Similar topics

3
14596
by: Meg | last post by:
Hi All, I am having a problem with paging in datagrid and need some idea as to how to handle the problem 1. the datagrid is first filled with a select * all 2. the datgrid shows 10 pages...
0
1100
by: jm | last post by:
I get this error when I click one of the datagrids pages: Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount. It is not doing this on the submit as I have this: Sub...
1
1807
by: CW | last post by:
Is this by design or is it a bug? If you have a pageable datagrid. After you delete a row from the grid (which results in a reduction in the number of pages of the datagrid), asp.net throws an...
3
7195
by: Clouds | last post by:
Hi ! How do I add the dynamic event handler for a dropdownlist present in the itemtemplate of a datalist !! I am doing it in the itemdatabound event of the datalist but it doesnt work... I am...
1
1554
by: Roy | last post by:
Hey all, This is a fairly broad question, but why is it that my datagrid hits the ItemDataBound event 3 times? Basically, I placed a response.write in all sub and functions in my codebehind and...
0
1011
by: JackO | last post by:
I can't seem to find a good example of how someone resolved the currentpageindex error that occurs when I try and page to another page on my datagrid. My subroutine is: Private Sub...
0
963
by: JackO | last post by:
I am still stuck trying to resolve the CurrentPageIndex problem. I have 3 pages in my datagrid and when I try to go to the second page, I get the error. I modified my code to: Private Sub...
2
2130
by: Ken Slight | last post by:
In C#, I use the following to bind ItemDataBound to a DataGrid: grid.ItemDataBound += new DataGridItemEventHandler(OnContentItemDataBound); Does anyone know the equivalent of this in vb.net? ...
1
1148
by: Rajani | last post by:
Hello, I am displaying data from database in datagrid. DG is having edit and delete features. Pagesize is 10. I have total 12 records(2 pages). Now i am deleting 12th and 11th records. Delete...
2
1910
by: rn5a | last post by:
In a shopping cart app, a ASPX page retrieves the order details & personal details of a user from a MS-Access database table depending upon the username of the user. The order details of a...
0
7049
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
6912
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6744
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...
0
6981
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...
0
5348
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,...
1
4790
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...
0
2989
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1304
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
565
muto222
php
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.