0

我已经从我的数据库中填充了组合框,RadGridView我希望当它处于添加模式时,我的组合框将其第一项显示为默认值。我使用了以下代码,但在调试代码中的注释行时出错

      private void radGridView_CellValueChanged(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
        {

                    if (e.Column.Name == "Productcolumn")
                {
//ERROR on debuging following line
                    RadDropDownListEditor ed = this.radGridView.Columns["UnitPrice"] as RadDropDownListEditor;
                    if (ed != null)
                    {
                        // the default selected Price that will be shown will be the first price, if no price is selected for the current cell
                        RadDropDownListEditorElement editorElement = (RadDropDownListEditorElement)ed.EditorElement;
                        editorElement.SelectedIndex = 0;
                    }
    }
    }
4

0 回答 0