ItemDataBound/CurrentPageIndex and DataGrids

L

Logician

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").ToString();

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.backgroundColor='azure';");
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor='white';");
}
 

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
474,262
Messages
2,571,055
Members
48,769
Latest member
Clifft

Latest Threads

Top