insert new record from combobox

2 posts, 0 answers
  1. Nick
    Nick avatar
    6 posts
    Member since:
    Feb 2011

    Posted 14 Apr 2011 Link to this post

    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>

  2. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1268 posts

    Posted 19 Apr 2011 Link to this post

    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.

Back to Top