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

AutoCompleteBox does not bind ID in EDIT mode

1 Answer 56 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Luis
Top achievements
Rank 1
Luis asked on 15 Jan 2015, 09:59 PM
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

ASP.NET
<
telerik:RadGrid ID="RadGrid1" runat="server"
            AllowAutomaticDeletes="True"
            AllowAutomaticInserts="True"
            AllowAutomaticUpdates="True"
            AllowFilteringByColumn="True"
            AllowPaging="True"
            AllowSorting="True"
            DataSourceID="SqlDataSource1"
            OnItemDataBound="RadGrid1_ItemDataBound"
            EnableLinqExpressions ="false">
 
            <MasterTableView AutoGenerateColumns="False" DataSourceID="SqlDataSource1" CommandItemDisplay="Top" DataKeyNames="product_name">
     
                <EditFormSettings EditFormType="Template">
                            <FormTemplate>
                    
                                            <telerik:RadAutoCompleteBox ID="radAutoCompleteBox1" runat="server"
                                                DataSourceID="SqlDataSource6"
                                                DataTextField="product_name"
                                                DataValueField="product_id"
                                                InputType="Text"
                                                Delimiter=" "
                                                SelectionMode="Single"
                                                Width="300"
                                                EmptyMessage="Type product name...">
                                            </telerik:RadAutoCompleteBox>
  
                                  
                            </FormTemplate>
                        </EditFormSettings>
            </MasterTableView>
        </telerik:RadGrid>
VB

Protected
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

1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 20 Jan 2015, 01:48 PM
Hello,

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

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

Regards,
Boyan Dimitrov
Telerik
 

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.

 
Tags
AutoCompleteBox
Asked by
Luis
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or