?
Solved

Use ASP.net Dropdownlist as FormParameter

Posted on 2009-04-24
2
Medium Priority
?
1,457 Views
Last Modified: 2012-05-06
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
Comment
Question by:MClarkCCR
2 Comments
 
LVL 14

Accepted Solution

by:
GiftsonDJohn earned 2000 total points
ID: 24225139
Hi

Use ControlParameter

<asp:ControlParameter ControlID="ddlTeamList" PropertyName="SelectedValue" Direction="Input" Type="Int32" Name="calendar_entry_id" />
0
 
LVL 3

Author Comment

by:MClarkCCR
ID: 24225265
That did the trick, thanks!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question