i have a listview with datapager attach to it , and when you clikc on an item you can edit/insert/delete this item in the details view control.
my problem was , when i add new item , so its added to the end of my list , mean to the last page, so if i wanted to continue edit it or chnage it , i needed to goto last page select it and edit it... bad idea...
so here is my solution on this
protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
{
// get the total items
int total = DataPager1.TotalRowCount;
// calc the last page
int pages = total / DataPager1.PageSize;
// set the pager to the last page
DataPager1.SetPageProperties(pages * DataPager1.PageSize, DataPager1.PageSize, true);
// bind again my listview
ListView1.DataBind();
// select the last one
ListView1.SelectedIndex = ListView1.Items.Count - 1;
/// boooom your new item show again in your detals view
}
enjoy
Yaniv Tzanany
No comments:
Post a Comment