My main issue is that my insertCommand is only picking up (and inserting it) the top item from the combobox and NOT the "Selected Item". What is missing in this code in order for my query to recognize the "Selected item " from my combobox. Here are the relevant pieces of my code:
<SCRIPT runat="server">
Sub On_Click(ByVal source As Object, ByVal e As EventArgs)
SqlDataSource2.Insert()
End Sub 'On_Click
</SCRIPT>
|
|
|
|-----------more code
|
|
|
<tr>
<td>
Categroy:
</td>
<td>
<telerik:RadComboBox ID="RadComboBox1" runat="server" DataSourceID="SqlDataSource2"
AppendDataBoundItems="true"
DataTextField="Category" DataValueField="CatId" Skin="Windows7"
DropDownWidth="298px" EmptyMessage="Choose a Category" HighlightTemplatedItems="true"
EnableLoadOnDemand="true" Filter="StartsWith" >
<HeaderTemplate>
<table style="width: 100px" cellspacing="0" cellpadding="0">
<tr>
<td style="width: 100px;">
Category Id</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table style="width: 100px" cellspacing="0" cellpadding="0">
<tr>
<td style="width: 100px;">
<%# Eval("CatId")%>
</td>
</tr>
</table>
</ItemTemplate>
</telerik:RadComboBox>
</td>
</tr>
|
|
|
|-----------more code
|
|
|
<tr>
<td colspan="2">
<br />
<br />
<asp:Button ID="btnAdd" runat="server" Text="Add New" OnClick="On_Click" />
</td>
</tr>
|
|
|
|-----------more code
|
|
|
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:MUNTERSJMmlConnectionString %>"
SelectCommand="SELECT MCategories.CatId FROM MCategories"
InsertCommand="INSERT INTO MProducts (CatId) VALUES (@CatId)">
<insertParameters>
<asp:ControlParameter Name="CatId" ControlId="RadComboBox1" PropertyName="SelectedValue" />
</insertParameters>
</asp:SqlDataSource>