"Carolyn Vo" wrote:
I have a datagrid in my web control class that I am trying to get the current
rows displayed for. I have enabled paging on the datagrid so if the user is
currently on page 3 of 8, and if I have allowed for the table to show only 5
rows at a time, for example, I want to get the 5 rows that are displayed on
page 3 of 8. How do I do this???? Thanks!
Hi Carolyn,
I think this post is better suited for
microsoft.public.dotnet.framewirk.aspnet
I have not clearly understood your problem but i guess you want to retrieve
the rows of a DataGrid which are displayed on the current page of datagrid.
If this is the problem, than i say this is not a problem as when you check
your datagrid on post back your datagrid will be having only those rows which
are displayed on the current page. As viewstate holds only the current page
of the datagrid not the entire datagrid.
Also your datagrid may be getting modified if you are calling DataBind()
again on postbacks, before processing the subset of rows you are interested
in.
This code snippet will give you better idea on how to select rows from
datagrid:
<CODE>
lblList.Text = "";
foreach(DataGridItem item in grdEmployee.Items)
{
if( item.ItemType == ListItemType.Item || item.ItemType ==
ListItemType.AlternatingItem)
// this is the row you are interested in, do your processing
lblList.Text += item.Cells[0].Text + " | " + item.Cells[1].Text + "<br>";
}
</CODE>
--
Cheers,
Rahul Anand