Avatar of marcus72
marcus72

asked on 

DropDownList in Formview InsertItemTemplate

Hi this I am building a form using the formview InsertItem Template.  When I connect to a datasource to the formview it generates a form using textboxes for the input controls; however, I would like to use other controls ie, a dropdownlist.  I don't want to populate the dropdown list from a datasource, I would like to hardcode the values in my dropdownlist ie, option1, option2, option3 etc.  When I do this the dropdownlist options repeat the same value "System.Data.DataRowView", is it possible to use other controls in a formview than textboxes and if so how can I capture the values from my dropdownlist to show in my form and then insert into my table?  Here is what my code looks like:




<asp:SqlDataSource ID="ASQCPAReportRequest" runat="server"
         ConnectionString="<%$ ConnectionStrings:WebAppsConnectionString %>"
          SelectCommand="SELECT * FROM [tbl_ReportRequest]"
          InsertCommand="Insert into [tbl_ReportRequest]
           ([Frequency]
          Values (@Frequency)">
          <InsertParameters>
            <asp:Parameter Name="Frequency" Type="string" />
          </InsertParameters>
        </asp:SqlDataSource>
 
<asp:FormView ID="FormView1" runat="server" AllowPaging="True" DataSourceID="ASQCPAReportRequest"
            DefaultMode="Insert" Width="305px" OnPageIndexChanging="FormView1_PageIndexChanging1">
 
          <InsertItemTemplate>
             <table border="1">
             <tr>
                <td align="right">
Frequency:
                </td>
                <td>
                   <asp:DropDownList ID="ddlFrequency" DataSourceID="ASQCPAReportRequest" DataValueField='<%# Bind("Frequency") %>' runat="server">
                    <asp:ListItem Text="Ad Hoc" Value="Ad Hoc">Ad Hoc</asp:ListItem>
                    <asp:ListItem Text="Daily" Value="Daily">Daily</asp:ListItem>
                    <asp:ListItem Text="Weekly" Value="Weekly">Weekly</asp:ListItem>
                    <asp:ListItem Text="Monthly" Value="Monthly">Monthly</asp:ListItem>
                    </asp:DropDownList>
                </td>
              </tr>
   </table>
            </InsertItemTemplate>
        </asp:FormView>

Open in new window

ASP.NET

Avatar of undefined
Last Comment
GreymanMSC

8/22/2022 - Mon