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

insert new record from combobox

1 Answer 56 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 14 Apr 2011, 07:31 PM
Hi,

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>

1 Answer, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 19 Apr 2011, 03:10 PM
Hello Nick,

You have already received a replay for your query in this forum thread here.

If you still experience the same issue, please open a support ticket so we could continue the discussion there.

Greetings,
Dimitar Terziev
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
ComboBox
Asked by
Nick
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Share this question
or