This is a migrated thread and some comments may be shown as answers.

RadGrid Edit Mode Paging

2 Answers 64 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brett
Top achievements
Rank 1
Brett asked on 15 Mar 2012, 09:03 PM
I have a radgrid that when the page loads all items are in edit mode. When I click to go to the next page all of the items on the next page aren't in edit mode. :( I gave to click "edit" for each item. I'd like for the next page to go into edit mode too.

This is what I'm using to get it into edit mode, which works for the first page.

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
        LinkButton lnkBtnDelete = (LinkButton)item["AutoGeneratedDeleteColumn"].Controls[0];
        lnkBtnDelete.Attributes["onclick"] = "javascript:return confirm(\'Do you want to delete this item?\')";
    }
    if (!Page.IsPostBack && e.Item is GridEditableItem)
    {
        e.Item.Edit = true;
    }
 
}

protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        foreach (GridItem item in RadGrid1.MasterTableView.Items)
        {
            if (item is GridEditableItem)
            {
                GridEditableItem editableItem = item as GridDataItem;
                editableItem.Edit = true;
            }
        }
        RadGrid1.Rebind();
    }
}



2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 Mar 2012, 05:17 AM
Hello Brett,

Try the following code in PreRender event.
C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
 for (int count = 0; count < RadGrid1.PageSize; count++)
 {
    RadGrid1.EditIndexes.Add(count);
 }
  RadGrid1.Rebind();
}
Hope this helps.

Thanks,
Shinu.
0
Kee Fai Foong
Top achievements
Rank 1
answered on 30 Sep 2012, 05:30 PM
I love u!!  This worked for me, took me hours to stumble upon this! Thanks
Tags
Grid
Asked by
Brett
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Kee Fai Foong
Top achievements
Rank 1
Share this question
or