In the following textbox, the text is populated with Minutely.
<telerik:RadTextBox ID="RadTextBox1" Runat="server" Text='<%# Eval("FREQUENCY") %>' />
I am trying select a combobox item based on the prexisting frequency. This code gives me a object not set to an instance of an object error:
<telerik:RadComboBoxItem runat="server" Text="One Time Run" Value="OneTimeRun" Selected='<%# (Eval("FREQUENCY").ToString() == "OneTimeRun" ? true : false) %>' />
I have tried the following ways to no success:
<telerik:RadComboBoxItem runat="server" Text="One Time Run" Value="OneTimeRun" Selected='<%# (Eval("FREQUENCY").ToString() == "OneTimeRun") %>' />
<telerik:RadComboBoxItem runat="server" Text="One Time Run" Value="OneTimeRun" Selected='<%# Eval("FREQUENCY").ToString() == "OneTimeRun" ? true : false %>' />
I don't understand what is wrong. If my textbox is being populated with the text "Minutely", why am I getting this error when I want to do comparison.
I guess you just can't use Eval on combo item since there's no datasource bound to it.
I suggest instead of trying to set Selected on your combo item, you should do the following: create a datasource of your items, bind the combo to the collection, set SelectedValue of the combo declaratively using Eval as you do now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With