Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在“中”打开Telerik RadGrid;添加新的“;预先填充默认值的模式?_C#_Asp.net_Telerik_Radgrid - Fatal编程技术网

C# 如何在“中”打开Telerik RadGrid;添加新的“;预先填充默认值的模式?

C# 如何在“中”打开Telerik RadGrid;添加新的“;预先填充默认值的模式?,c#,asp.net,telerik,radgrid,C#,Asp.net,Telerik,Radgrid,从超链接中,我需要在RadGrid弹出窗口以“添加新”模式打开时显示默认值。单击RadButton时,它可以正常工作(CommandName=“InitInsert”)。为此,我在RadGrid\u ItemCommand中设置了默认值: if (e.CommandName == RadGrid.InitInsertCommandName) { e.Canceled = true; Hashtable values = GetDefaultValues(); e.Ite

从超链接中,我需要在RadGrid弹出窗口以“添加新”模式打开时显示默认值。单击RadButton时,它可以正常工作(
CommandName=“InitInsert”
)。为此,我在
RadGrid\u ItemCommand
中设置了默认值:

if (e.CommandName == RadGrid.InitInsertCommandName)
{
    e.Canceled = true; 
    Hashtable values = GetDefaultValues();
    e.Item.OwnerTableView.InsertItem(values); 
}

RadGrid的
MasterTableView
具有
EditMode=“PopUp”
。要使弹出窗口从链接中出现,我在
查询字符串中传递了文本“AddNew”。然后在
PageLoad
I中设置
RadGrid.MasterTableView.IsItemInserted=true。我不明白的是,如何在由超链接触发的弹出窗口中显示默认值?非常感谢代码示例。

您是否尝试过绑定EditItemTemplate中的控件?Text=''我计划使用代码隐藏。默认值将是用户名、添加的日期、客户代码等。我不知道是否可以使用绑定进行绑定,但我会研究它。如果要在代码隐藏中进行绑定,请在itemdatabound事件中进行,然后检查网格是否处于编辑模式。然后通过引用您选择的行,从代码隐藏中设置模板中控件的值。听起来不错。你能用代码示例发布答案吗?
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;
        }
    }
}