Afternoon All,
I am used to using gridviews but i am using a a details view for the first time. I am using Visual Studio 2010 with VB code.
I have a grid view that displays items from a database table and uses the 'ShowSelectButton="true"' function to enable users to select these individual items and display the full information within a details view.
The above works fine. The only issue that i have is my data is bound to the datasource and the associated database. On one of these columns i want to enable the users to select an item (Action Status and update - Outstaning, In-progress & Completed) in the form of a drop down list and then update it.
Im not too sue how to complete this? Here is my code for the details view....
<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="400px"
AutoGenerateRows="False"
DataKeyNames="ActionID" DataSourceID="dsDetailsView"
AutoGenerateEditButton="True" CssClass="mGrid" PagerStyle-CssClass="pgr"
AlternatingRowStyle-CssClass="alt" HorizontalAlign="Center"
CellPadding="5" >
<AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>
<Fields>
<asp:BoundField DataField="AgendaID" HeaderText="Agenda Ref:"
SortExpression="AgendaID" ReadOnly="true">
<HeaderStyle Font-Bold="True" Font-Names="Ariel" />
</asp:BoundField>
<asp:BoundField DataField="ActionID" HeaderText="Action ID:"
InsertVisible="False" ReadOnly="True" SortExpression="ActionID"
ItemStyle-Width="500px" >
<HeaderStyle Font-Bold="True" />
<ItemStyle Width="500px" Font-Bold="True"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="Action" HeaderText="Action:"
SortExpression="Action" ReadOnly="true">
<HeaderStyle Font-Bold="True" />
<ItemStyle Wrap="True" />
</asp:BoundField>
<asp:BoundField DataField="Owner" HeaderText="Owner:"
SortExpression="Owner" ReadOnly="true">
<HeaderStyle Font-Bold="True" Wrap="False" />
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="TargetDate" HeaderText="Target Date:"
SortExpression="TargetDate" ReadOnly="true"
DataFormatString="{0:dd-MM-yyyy} " >
<HeaderStyle Font-Bold="True" Wrap="True" />
<ItemStyle Font-Bold="False" />
</asp:BoundField>
<asp:BoundField DataField="DateCreated" HeaderText="Date Created:"
SortExpression="DateCreated" ReadOnly="true"
DataFormatString="{0:dd-MM-yyyy} " >
<HeaderStyle Font-Bold="True" Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="ActionUpdate" HeaderText="Action Update:"
SortExpression="ActionUpdate"
NullDisplayText="Select 'Edit' to update Action..." >
<HeaderStyle Font-Bold="True" Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="ActionStatus" HeaderText="Action Status:"
SortExpression="ActionStatus" ReadOnly="true" >
<HeaderStyle Font-Bold="True" Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="ActionStatusID" HeaderText="Action Status ID:"
SortExpression="ActionStatusID" ReadOnly="true" Visible="true">
<HeaderStyle Font-Bold="True" Wrap="False" />
</asp:BoundField>
</Fields>
<PagerStyle CssClass="pgr" />
</asp:DetailsView>
Any help in advance is much appriechiated.
Regards Betty
You want to use a
Templatefield
, rather than aBoundField
for "ActionStatus" to accomplish this.You can use the designer to convert the field to a
TemplateField
as follows:DetailsView
(I can't remember what it's called), thenThen you need to go to your markup (the source view) and change the
<EditItemTemplate>
section so it has aDropDownList
inside it. Like this:You will also need to make sure that your DataSource has a "UpdateCommand" configured in order for the update to work properly.