将Combobox SelectedItem.Text指定为String

时间:2012-07-18 17:54:32

标签: c# asp.net combobox oracle10g

尝试将“model”中的值分配到名为ModelNumTB的Combobox时,我收到以下异常。

由于某种原因,我无法将其复制到字符串的值到Combobox的默认加载值。你怎么这么做的?      字符串模型;

 <ajaxToolkit:ComboBox ID="ModelNumTB" runat="server" 
                    AutoCompleteMode="Suggest" AutoPostBack="True" DataSourceID="ComboboxDS" 
                    DataTextField="MODEL_NUMBER" DataValueField="MODEL_NUMBER" MaxLength="0" 
                    style="display: inline;" 
                    onselectedindexchanged="ModelNumTB_SelectedIndexChanged"></ajaxToolkit:ComboBox>

Null Reference Exception

将其更改为以下内容也不起作用:

enter image description here

1 个答案:

答案 0 :(得分:1)

更改

ModelNumTB.SelectedItem.Text = model;

为:

ModelNumTB.Text = model;

SelectedItem属性为null