I have a Combobox where the list can be edited and I'm trying to update the text which is read from 2 database tables but I'm having trouble doing that.
Customer Table: CustomerID and Customername (Lookup Table)
Product Table: Customer (Contains the CustomerID from Customer Table)
<cc1:ComboBox ID="ComboBoxCustomer" runat="server" AppendDataBoundItems="True" AutoCompleteMode="SuggestAppend" AllowCustomText="True" DataSourceID="SqlDataSourceCustomer" DataTextField="CustomerName" AutoPostBack="True" SelectedValue='<%# Bind("Customer") %>' Width="75px" DataValueField="CustomerID" MaxLength="0" style="display: inline;" oniteminserted="ComboBoxCustomer_ItemInserted"> <asp:ListItem Text="Select/Enter New Value" Value="" /> </cc1:ComboBox>
<asp:SqlDataSource ID="SqlDataSourceCustomer" runat="server" ConnectionString="<%$ ConnectionStringsBConnectionString %>" SelectCommand="SELECT * FROM [Customer]"></asp:SqlDataSource>
UpdateCommand= " UPDATE Product SET [Description] = @Description, [Customer] = @customerIndex WHERE ProductID = @ProductID; UPDATE Customer Set CustomerName = @Customer WHERE CustomerID=@customerIndex;
Protected Sub ComboBoxCustomer_ItemInserted(ByVal sender As Object, ByVal e As AjaxControlToolkit.ComboBoxItemInsertEventArgs)
Dim CustomerItem As String = ComboBoxCustomer.SelectedItem
Dim CustomerIndex As Integer = ComboBoxCustomer.SelectedIndex
End Sub
I either get a conversion error or object error:
Conversion failed when converting the nvarchar value 'Simpson' to data type int.
I haven't been able to find any documentation on how to go about doing this.
Thanks so much for your help.
Customer Table: CustomerID and Customername (Lookup Table)
Product Table: Customer (Contains the CustomerID from Customer Table)
<cc1:ComboBox ID="ComboBoxCustomer" runat="server" AppendDataBoundItems="True" AutoCompleteMode="SuggestAppend" AllowCustomText="True" DataSourceID="SqlDataSourceCustomer" DataTextField="CustomerName" AutoPostBack="True" SelectedValue='<%# Bind("Customer") %>' Width="75px" DataValueField="CustomerID" MaxLength="0" style="display: inline;" oniteminserted="ComboBoxCustomer_ItemInserted"> <asp:ListItem Text="Select/Enter New Value" Value="" /> </cc1:ComboBox>
<asp:SqlDataSource ID="SqlDataSourceCustomer" runat="server" ConnectionString="<%$ ConnectionStringsBConnectionString %>" SelectCommand="SELECT * FROM [Customer]"></asp:SqlDataSource>
UpdateCommand= " UPDATE Product SET [Description] = @Description, [Customer] = @customerIndex WHERE ProductID = @ProductID; UPDATE Customer Set CustomerName = @Customer WHERE CustomerID=@customerIndex;
Protected Sub ComboBoxCustomer_ItemInserted(ByVal sender As Object, ByVal e As AjaxControlToolkit.ComboBoxItemInsertEventArgs)
Dim CustomerItem As String = ComboBoxCustomer.SelectedItem
Dim CustomerIndex As Integer = ComboBoxCustomer.SelectedIndex
End Sub
I either get a conversion error or object error:
Conversion failed when converting the nvarchar value 'Simpson' to data type int.
I haven't been able to find any documentation on how to go about doing this.
Thanks so much for your help.