Automatically select a row or page

E

et

I fill a paged datagrid based on an item the user clicks, which returns an
ID. The dgrid's datasource contains several records, but I want it to open
and automatically select the row or go to a particular page based on the id
field of the grid. How can I do this?

Thanks for your help.
 
E

Elton Wang

You can 'pass' the ID to the particular page by Cookie, Session, or
Querystring and redirect to the page. Then in the page, retrieve the ID and
get data based on the ID.

HTH
 
E

et

I already pass the id to the page by query string and I open the page. That
works fine. I want the grid to contain all records, not just the one
pertaining to the selected id, so they can still select Prev/Next to scroll
through the items. However, I want the grid to automatically select the
item in the grid according to the id when the grid is first filled. Not
just fill the grid with one record. I hope that makes sense. In other
words something like dg.SelectedIndex = ????? Or dg.CurrentlySelectedPage ==
??????
 
E

Elton Wang

You can set the selectedrow's background color in datagrid_ItemDataBound
event:

if (ID)
{
e.Item.BackColor = Color.Blue;
}

HTH
 

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

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,602
Members
45,185
Latest member
GluceaReviews

Latest Threads

Top