How do I set Telerik RadGrid to Edit mode by default? (ASP.NET)

回眸只為那壹抹淺笑 提交于 2019-12-09 12:36:45

问题


I have a checkbox column in a RadGrid that I want the user to be able to check/uncheck it and set the attached property. When the grid renders however, the checkboxes are disabled, because the grid is not in "edit mode". All the examples I'm finding want me to go through a lengthy process of selecting the record, putting it into edit mode, changing the value, saving the value.... yada yada yada...

I just want the whole grid to be in edit mode (or the column, or whatever works) from the get-go, so the end user can make a one-click change to the data value.

I know there must be a way to do this, I just can't seem to find it.

Help?


回答1:


You can put it into edit mode by calling on the pre-render event for the grid.

Here is some sample C# code to do that.

protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    if (IsPostBack) return;

    foreach (var item in RadGrid1.MasterTableView.Items)
    {
        var editableItem = item as GridEditableItem;
        if (editableItem == null) continue;

        editableItem.Edit = true;
        PreviewRadGrid.Rebind();
    }       
}

http://www.telerik.com/help/aspnet/grid/grddefaulteditmodeforgriditemsoninitialload.html



来源:https://stackoverflow.com/questions/4379448/how-do-i-set-telerik-radgrid-to-edit-mode-by-default-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!