Allen Buckley's Blog
My experiences in .Net

Replace text area in DetailsView with a DDL

Wednesday, August 02, 2006 7:58 PM

This inline code is used to insert a dropdownlist into a datagrid/detailsview control in place of a given text area when using the InsertItemTemplate.  The reason for doing this is to force the user to submit a answer out of options you choose to give, rather then letting them enter an open ended answer which you might not need or want.

The BoundField is Title.

<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />


InsertItemTemplate

<InsertItemTemplate>
<
asp:DropDownList ID="DropDownList1" runat="server" SelectedValue='<%# Request.Querystring("testid") %>'  DataSourceID="SqlDataSource2" DataTextField="Title" DataValueField="QuizID">

</
asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:quizConnectionString %>"SelectCommand="SELECT [Title], [QuizID] FROM [Quiz]">
</asp:SqlDataSource>
</InsertItemTemplate>


Feedback

No comments posted yet.


Post a comment