简体   繁体   English

如何在“添加新”模式下打开预填默认值的Telerik RadGrid?

[英]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" . MasterTableViewMasterTableView具有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.

相关问题 如何关闭Telerik Radgrid的默认编辑模式? - How do I close default edit mode of Telerik Radgrid? 如何将新项目添加到linq预填充的列表中? - How to add a new item to a list pre-filled by linq? 单击Telerik radgrid中的“添加新记录”时,如何访问列中的文本框 - how do I access the textbox in a column when I click “Add new record” in the telerik radgrid telerik radgrid-如何在单击“添加新记录”按钮以添加记录后将页面焦点设置为“插入”按钮 - telerik radgrid - how do I set the page focus to the insert button after clicking the add new record button to add a record 添加新记录到 Telerik RadGrid - Add new record to Telerik RadGrid 如何以编程方式将动态数据添加到Telerik Radgrid的字幕中? - How can I add dynamic data to the Caption in the Telerik Radgrid programmatically? .NET createuserwizard-如何提供预填充(和禁用)的电子邮件字段 - .NET createuserwizard - how to provide a pre-filled (and disabled) email field 如何向Telerik Open Access MVC项目添加新表? - How do I add a new table to a Telerik Open Access MVC project? Telerik RadGrid-如何为“插入”文本框设置MaxLength - Telerik RadGrid - How do I set the MaxLength for the Insert Textbox 模板上的预填充/发件人选项卡 - Pre-Filled/Sender's Tabs on a Template
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM