This is a migrated thread and some comments may be shown as answers.

AllowCustomText in ComboBox In Grid

1 Answer 30 Views
Grid
This is a migrated thread and some comments may be shown as answers.
TPerry
Top achievements
Rank 1
TPerry asked on 29 Oct 2008, 03:43 PM
Hello - I have a RadGrid with a GridTemplateColumn, as my code shows below.  In this column is a ComboBox, which I want to give users the choice to either choose an existing item or type in a new item.  This works if they choose an existing item, but if they type in a new item, when it goes to insert the new row, it loses the value of the custom text.  You can see where I am testing it below.  What am I missing?

<

 

telerik:GridTemplateColumn UniqueName="CompanyName" HeaderText="Company Name" DataField="CompanyName"> 
    
<ItemTemplate
            
<asp:Label ID="lblVendorID" runat="server" Text='<%# Eval("CompanyName")%>'></asp:Label
    
</ItemTemplate>
    
<EditItemTemplate
        
<telerik:RadComboBox ID="ddlCompanyName" runat="server" DataTextField="CompanyName" DataValueField="CompanyName" MarkFirstMatch="true" SelectedValue='<%# Bind("CompanyName") %>'  DataSourceID="SDSVendorCompany" AppendDataBoundItems="true" AllowCustomText="true"> 
                <Items><telerik:RadComboBoxItem Text="- Select One -" Value="" /></Items>     
        <
/telerik:RadComboBox
    
</EditItemTemplate>
    
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top" /> </telerik:GridTemplateColumn>

I"m testing it here, and if I type in a new value, the value of test is always 'Nothing'.  If I choose an existing value, it works great.

Protected
Sub SDSVendors_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SDSVendors.Inserting

 

 

 

 

Dim test As String = e.Command.Parameters("@CompanyName").Value

 

 E

nd Sub  

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 31 Oct 2008, 11:46 AM
Hi TPerry,

When adding the items to the combo, you can save them in the underlying database. How are you adding the new item(s) to the combo?

Best wishes,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
TPerry
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or