ASPX ComboBox对象空引用异常

时间:2016-10-14 08:14:11

标签: c# webforms devexpress

当我设置值ASPXCombobox时。来自null ref异常;

<td>
                                            <dxe:ASPxComboBox ID="cmb" runat="server" AutoPostBack="True" ClientInstanceName="cmb"
                                                EnableCallbackMode="True" EnableSynchronization="False" CallbackPageSize="20" Width="300px"
                                                IncrementalFilteringMode="Contains"
                                                LoadingPanelText="Yükleniyor&hellip;" Theme="Aqua">
                                            </dxe:ASPxComboBox>
                                        </td>

  Test tt = new Test();
    DataTable dt = paf.GetAllItem();
    cmb.ValueField = "ID";
    cmb.TextField = "NAME";
    cmb.DataSource = dt;
    cmb.DataBind();
    cmbMahPafta.SelectedIndex = -1;

我使用该代码后出现错误。

 cmbMahPafta.SelectedItem.Value=user.ID;//Null reference Exception.

如何解决此问题?

0 个答案:

没有答案