• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1540
  • Last Modified:

Use ASP.net Dropdownlist as FormParameter

Hello,

I have a Telerik RadScheduler in my webapp that is databound to a SqlDataSource on the same .aspx page.  I am trying to set up a FormParameter in my select, insert, and update parameters that uses the value from a dropdownlist 'ddlTeamList'.  So far I haven't been able to figure it out.

The code is for my SqlDataSource and you should be able to see where I am trying to use the FormParameter and how I am trying to use it.  Unfortunately, when I insert a new appointment into the calendar, the subsequent DB record that is created shows NULL for the value of team_id which I am trying to get from the DDL.  Can anyone let me know what I might be doing wrong?

TIA,

Mike
<asp:sqldatasource id="dsrcONSCalendar" runat="server" 
                        connectionstring="<%$ ConnectionStrings:onsConnectionString %>" 
                        deletecommand="DELETE FROM [ons_user_calendar] WHERE [calendar_entry_id] = @calendar_entry_id" 
                        insertcommand="INSERT INTO [ons_user_calendar] ([calendar_start_date], [calendar_end_date], [calendar_entry_category_id], [calendar_entry_description], [team_id], [calendar_recurrence_rule], [calendar_recurrence_parent_id]) VALUES (@calendar_start_date, @calendar_end_date, @calendar_entry_category_id, @calendar_entry_description, @team_id, @calendar_recurrence_rule, @calendar_recurrence_parent_id)" 
                        selectcommand="SELECT * FROM [ons_user_calendar] WHERE [team_id] = @team_id" 
                        updatecommand="UPDATE [ons_user_calendar] SET [calendar_start_date] = @calendar_start_date, [calendar_end_date] = @calendar_end_date, [calendar_entry_category_id] = @calendar_entry_category_id, [calendar_entry_description] = @calendar_entry_description, [team_id] = @team_id, [calendar_recurrence_rule] = @calendar_recurrence_rule, [calendar_recurrence_parent_id] = @calendar_recurrence_parent_id WHERE [calendar_entry_id] = @calendar_entry_id">
                        <selectparameters>
                            <asp:FormParameter name="team_id" FormField="ddlTeamList" />
                            <%--<asp:querystringparameter name="team_id" querystringfield="tid" type="Int32" />--%>
                        </selectparameters>
                        <deleteparameters>
                            <asp:parameter name="calendar_entry_id" type="Int32" />
                        </deleteparameters>
                        <updateparameters>
                            <asp:parameter name="calendar_start_date" type="DateTime" />
                            <asp:parameter name="calendar_end_date" type="DateTime" />
                            <asp:parameter name="calendar_entry_category_id" type="Int32" />
                            <asp:parameter name="calendar_entry_description" type="String" />
                            <asp:FormParameter name="team_id" FormField="ddlTeamList" />
                            <asp:parameter name="calendar_recurrence_rule" type="String" />
                            <asp:parameter name="calendar_recurrence_parent_id" type="Int32" />
                            <asp:parameter name="calendar_entry_id" type="Int32" />
                        </updateparameters>
                        <insertparameters>
                            <asp:parameter name="calendar_start_date" type="DateTime" />
                            <asp:parameter name="calendar_end_date" type="DateTime" />
                            <asp:parameter name="calendar_entry_category_id" type="Int32" />
                            <asp:parameter name="calendar_entry_description" type="String" />
                            <asp:FormParameter name="team_id" FormField="ddlTeamList" type="Int32" />
                            <asp:parameter name="calendar_recurrence_rule" type="String" />
                            <asp:parameter name="calendar_recurrence_parent_id" type="Int32" />
                        </insertparameters>
                    </asp:sqldatasource>

Open in new window

0
MClarkCCR
Asked:
MClarkCCR
1 Solution
 
GiftsonDJohnCommented:
Hi

Use ControlParameter

<asp:ControlParameter ControlID="ddlTeamList" PropertyName="SelectedValue" Direction="Input" Type="Int32" Name="calendar_entry_id" />
0
 
MClarkCCRAuthor Commented:
That did the trick, thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now