This is a migrated thread and some comments may be shown as answers.
RadComboBox are going to be the Death of me
1 Answer 3 Views
This is a migrated thread and some comments may be shown as answers.
SSirica
Top achievements
Rank 1
SSirica asked on 22 Feb 2021, 08:06 PM

 

I have the following Combobox

<telerik:RadComboBox ID="cbAcctType" runat="server" DataValueField="ACCT_TYPE_ID" DataTextField="acct_code" RenderMode="Classic"
    AutoPostBack="True" CausesValidation="False" Width="100%" DropDownWidth="400px" HighlightTemplatedItems="True"
    InputCssClass="required_cb" EnableLoadOnDemand="true" AppendDataBoundItems="True">
    <ItemTemplate>
        <asp:Table runat="server" CellPadding="0" CellSpacing="0" Width="100%" GridLines="None">
            <asp:TableRow>
                <asp:TableCell Width="30%">
                    <%# DataBinder.Eval(Container.DataItem, "acct_code") %>
                </asp:TableCell>
                <asp:TableCell Width="70%">
                    <%# DataBinder.Eval(Container.DataItem, "acct_description") %>
                </asp:TableCell>
            </asp:TableRow>
        </asp:Table>
    </ItemTemplate>
</telerik:RadComboBox>

 

and I bind it with the following code:

cbAcctType.DataSource = ds.Tables("AcctType")
cbAcctType.DataBind()

 

Sometimes the code associated with an account will expire and no longer be available in the available list, but it still exists so I have to individually retrieve it and add it to the combobox list.  Here is my code for that process

Dim oItem As New RadComboBoxItem
oItem.DataItem = ds.Tables(0).Rows(0)
oItem.Value = ds.Tables(0).Rows(0).Item("ACCT_TYPE_ID").ToString
oItem.Text = ds.Tables(0).Rows(0).Item("acct_code").ToString
oItem.Selected = True
cbAcctType.Items.Add(oItem)

 

And that's where the wheels come off.  The items is there but only sort of.  It will get selected but there is no items in the list.  and it usually throws and ASPX page error the <%# DataBinder.Eval(Container.DataItem, "acct_code") %> doesn't exist.

What is the piece of the puzzle that's missing?  I have tried it with oItem.DataBind() and that doesn't solve things. 

1 Answer, 1 is accepted

Sort by
0
SSirica
Top achievements
Rank 1
answered on 23 Feb 2021, 04:22 PM

I mean what is the purpose of the RadComboBoxItem having a .DataItem property if nothing in the combobox is going to pickup any of the items values?  It should be the single item equivalent of .DataSource.  

I swear people who design these things don't actually use them or design them with the simplest of scenarios.  Don't even get me started on the  RadMultiColumnComboBox.  That should have been released with an Alpha version warning. It's like the RadComboBox, but almost nothing is the same.  It's a Fiero with a Ferrari body.  

Asked by
SSirica
Top achievements
Rank 1
Answers by
SSirica
Top achievements
Rank 1
Share this question
or