AllowCustomText inside RadGrid

2 posts, 0 answers
  1. Derek
    Derek avatar
    118 posts
    Member since:
    Oct 2008

    Posted 06 Jun 2010 Link to this post

    One of my developers is trying to use an autocomplete column inside a Radgrid. We configured a dropdown column which uses a "select distinct" statement to get the unique existing values in the field, and then used that as source for the dropdowncolumn. Here's the column.

    <telerik:GridDropDownColumn DataField="MadeBy" HeaderText="MadeBy"
                SortExpression="MadeBy" UniqueName="MadeBy" DataSourceID="dsMadeBy" ListTextField="MadeBy"     ListValueField="MadeBy">
    </telerik:GridDropDownColumn>


    In code-behind, we've set up the AllowCustomText and MarkFirstMatch properties as follows;

        Protected Sub RadGridItems_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGridItems.ItemDataBound
            ' try and set the allowcustomtext property on the dropdown
            If TypeOf (e.Item) Is GridEditableItem And e.Item.IsInEditMode Then
                Dim edititem As GridEditableItem = e.Item
                Dim combo As RadComboBox = edititem("MadeBy").Controls(0)
                combo.AllowCustomText = True
                combo.MarkFirstMatch = True
            End If
        End Sub

    This seems to work, and we are able to enter new text, but nothing is saved and the Update section remains on the screen. Are we missing something?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 07 Jun 2010 Link to this post

    Hello Derek,

    One suggestion in this case would be access the RadComboBox value and update it from code behind. Sample code is given below.

    VB.Net
    Protected Sub RadGrid1_UpdateCommand(source As Object, e As GridCommandEventArgs) 
        Dim edititem As GridEditableItem = DirectCast(e.Item, GridEditableItem) 
        Dim combo As RadComboBox = DirectCast(edititem("MadeBy").Controls(0), RadComboBox) 
        Dim newvalue As String = combo.Text 
        'update query 
    End Sub 
     

    Regards,
    Shinu.



  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top