Telerik的radgrid控件 - 如何我默认为编辑模式?
题
我想让我的radgrid控件的项目是在页面加载编辑。我已经试过这两种方法在这里 http://www.telerik.com/help /aspnet/grid/grddefaulteditmodeforgriditemsoninitialload.html 但既不产生任何效果。
用于实施例中的第二方法,下面,说明由编辑属性设置在ItemCreated事件中所示,使在编辑模式中被设置为真(由调试器验证),但在显示页面时,对结果没有任何影响。
任何人有任何想法我做错了吗?
protected void RadGrid1_ItemCreated(object sender, Telerik.WebControls.GridItemEventArgs e)
{
if (!Page.IsPostBack && e.Item is GridEditableItem)
{
e.Item.Edit = true;
}
}
解决方案
此工作的:
for (int i = 0; i < RadGrid1.PageSize; i++)
{
RadGrid1.EditIndexes.Add(i);
RadGrid1.Rebind();
}
其他提示
这也适用:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
e.Item.Edit = true;
}
下面的代码可以用于,如果你想要做如上所述但对于子表:
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();
}
不隶属于 StackOverflow