【问题标题】:Access RadGrid EditForm template items in Insert & Edit events from RadDropDownList selectedindexchanged从 DropDownList selectedindexchanged 访问插入和编辑事件中的 RadGrid 编辑表单模板项
【发布时间】:2018-08-23 03:26:08
【问题描述】:

我的 Telerik RadGrid 中有一个 Telerik RadDropDownList,它的编辑模式是 FormTemplate。当我更改 RadDropDownList 时,它在插入模式下运行良好,但在编辑模式下出现错误。

InvalidCastException = "无法将 'Telerik.Web.UI.GridEditFormItem' 类型的对象转换为 'Telerik.Web.UI.GridEditFormInsertItem' 类型。"

protected void TransactionTypeTextBox_SelectedIndexChanged(object sender, DropDownListEventArgs e)
    {
        RadDropDownList dropdownlist1 = (RadDropDownList)sender;
        GridEditFormInsertItem item = (GridEditFormInsertItem)dropdownlist1.NamingContainer;
        Panel Panel1 = (Panel)item.FindControl("Panel1");
        if (dropdownlist1.SelectedItem.Text == "Cheque")
        {
            Panel1.Visible = true;
        }
        else if (dropdownlist1.SelectedItem.Text == "Cash")
        {
            Panel1.Visible = false;
        }
    }

【问题讨论】:

    标签: c# asp.net telerik dropdown radgrid


    【解决方案1】:

    由于 GridEditFormInsertItem 是从 GridEditFormItem 派生的,因此以下两种情况都适用。

    GridEditFormItem item = (GridEditFormItem)dropdownlist1.NamingContainer;
    

    【讨论】:

      猜你喜欢
      • 2012-03-31
      • 2014-11-27
      • 1970-01-01
      • 2014-09-02
      • 1970-01-01
      • 1970-01-01
      • 2012-09-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多