Telerik RadGrid - How do I default to edit mode?
Asked Answered
J

3

8

I want to make the items of my RadGrid be editable on page load. I've tried both methods here http://www.telerik.com/help/aspnet/grid/grddefaulteditmodeforgriditemsoninitialload.html but neither have any effect.

The 2nd method for example, shown below where the Edit property is set on the ItemCreated event, causes the Edit mode to be set true (verified by debugger) but it has no effect on the results when the page is displayed.

Anyone have any ideas what I'm doing wrong?

protected void RadGrid1_ItemCreated(object sender, Telerik.WebControls.GridItemEventArgs e)
{
    if (!Page.IsPostBack && e.Item is GridEditableItem)
   {
       e.Item.Edit = true;
   }
}
Jigging answered 23/3, 2009 at 17:13 Comment(2)
possible duplicate of How do I set Telerik RadGrid to Edit mode by default? (ASP.NET)Shrewmouse
The link provided in the question doesn't work--it goes to what looks like a guide for radgrids, but shows no content, just blank white space, where words would go.Conclusion
J
9

This works:

for (int i = 0; i < RadGrid1.PageSize; i++)
{
    RadGrid1.EditIndexes.Add(i);
    RadGrid1.Rebind();
}
Jigging answered 24/3, 2009 at 11:25 Comment(0)
A
8

This also works:

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    e.Item.Edit = true;
}
Alley answered 18/6, 2009 at 18:21 Comment(0)
C
1

the code below can be used if you'd like to do as described above but for child tables:

protected void RadGrid1_PreRender(object sender, EventArgs e)  
{  
    foreach (GridDataItem item in RadGrid1.MasterTableView.Items)  
    {  
        if (item.HasChildItems)  
        {  
            GridTableView childTable = (GridTableView)item.ChildItem.NestedTableViews[0];  


            foreach (GridDataItem childitem in childTable.Items)  
            {  

               //Check for the newly inserted row 
               //and set in edit mode 
               //childitem.Edit=true; 
            }  
        }  
    }  
    RadGrid1.MasterTableView.Rebind();  
}  
Certiorari answered 27/3, 2013 at 3:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.