Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combobox Updating

Status
Not open for further replies.

mana2

Programmer
Aug 9, 2002
116
US
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="<%$ ConnectionStrings:DBConnectionString %>" 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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top