AutoCompleteBox does not bind ID in EDIT mode

2 posts, 0 answers
  1. Luis
    Luis avatar
    1 posts
    Member since:
    Oct 2014

    Posted 15 Jan 2015 Link to this post

    I follow several samples and nothing seems wrong with my code, but I still receiving a NULL value error when I try to insert a value. The product_id parameter is not binded and pass onto the INSERT SQL statement. Here is my code

    telerik:RadGrid ID="RadGrid1" runat="server"
                EnableLinqExpressions ="false">
                <MasterTableView AutoGenerateColumns="False" DataSourceID="SqlDataSource1" CommandItemDisplay="Top" DataKeyNames="product_name">
                    <EditFormSettings EditFormType="Template">
                                                <telerik:RadAutoCompleteBox ID="radAutoCompleteBox1" runat="server"
                                                    Delimiter=" "
                                                    EmptyMessage="Type product name...">

    Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs)
            If e.Item.IsInEditMode Then
                Dim item As GridEditableItem = DirectCast(e.Item, GridEditableItem)
                If Not (TypeOf e.Item Is IGridInsertItem) Then
                    Dim radAutoCompleteBox1 As RadAutoCompleteBox = DirectCast(item.FindControl("radAutoCompleteBox1"), RadAutoCompleteBox)
                    radAutoCompleteBox1.Entries.Add(New AutoCompleteBoxEntry(item("product_name").Text, item("product_name").Text))
                End If
            End If
        End Sub
  2. Boyan Dimitrov
    Boyan Dimitrov avatar
    1968 posts

    Posted 20 Jan 2015 Link to this post


    I would suggest using the <asp:SessionParameter ...> to store the selected item id. You can set it as shown below:
    //markup code
                <asp:Parameter Name="ProductName" Type="String" />
                <asp:SessionParameter SessionField="SupplierID" Name="SupplierID" Type="Int32" />
                <asp:Parameter Name="CategoryID" Type="Int32" />

    When you select a new item in the RadAutoCompleteBox you can set it in the Session. Please use this demo as reference.

    Boyan Dimitrov

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top