[英]How do I open a Telerik RadGrid in “Add New” mode with default values pre-filled?
From a hyperlink I need default values to appear when a RadGrid PopUp opens in "Add New" mode. 从超链接中,我需要在“添加新”模式下打开RadGrid弹出窗口时显示默认值。 It works fine when a RadButton is clicked ( CommandName="InitInsert"
). 单击RadButton( CommandName="InitInsert"
)时,它可以正常工作。 For that I set defaults in the RadGrid_ItemCommand
: 为此,我在RadGrid_ItemCommand
设置了默认值:
if (e.CommandName == RadGrid.InitInsertCommandName)
{
e.Canceled = true;
Hashtable values = GetDefaultValues();
e.Item.OwnerTableView.InsertItem(values);
}
The RadGrid's MasterTableView
has EditMode="PopUp"
. MasterTableView
的MasterTableView
具有EditMode="PopUp"
。 To cause the PopUp to appear from a link I've passed the text "AddNew" in the queryString
. 为了使PopUp从链接中显示,我在queryString
传递了文本“ AddNew”。 Then in PageLoad
I set RadGrid.MasterTableView.IsItemInserted = true;
然后在PageLoad
我设置RadGrid.MasterTableView.IsItemInserted = true;
as described here . 如此处所述 。 What I can't figure out is how do I get default values to appear in the PopUp that is triggered from a hyperlink? 我不知道如何使默认值显示在通过超链接触发的PopUp中? A code sample would be much appreciated. 代码示例将不胜感激。
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if(e.Item is GridEditableItem && e.Item.IsInEditMode)
{
if(e.Item is GridEditFormItem)
{
GridEditFormItem item = (GridEditFormItem)e.Item;
TextBox TextBox1 = (TextBox)item.FindControl("TextBox1");
TextBox1.Text = item["column"].Text;
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.