views:

89

answers:

0

I am using an SPGridView within a custom control to display data from a list. However, I want the user to be able to edit that data dynamically, so I have bound text boxes to each column within the list using TemplateFields. When an update button on the control is clicked, the control goes through each text box and updates its corresponding bound field. A sample of my current code is below

<ContentTemplate>
    <SharePoint:SPGridView id="gridView1" runat="server" AutoGenerateColumns="False" BorderColor="#CCCCCC" Width="20%"
                BorderStyle="None" BorderWidth="1px" BackColor="White" AllowPaging="true">
        <Columns>
            <asp:TemplateField HeaderText="ID" >
                <ItemTemplate>
                    <asp:Label EnableViewState="true" Visible="false" id="lblID" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.ID") %>'>
                    </asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Title" >
                <ItemTemplate>
                    <asp:TextBox EnableViewState="true" id="txtTitle" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Title") %>'>
                    </asp:TextBox>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>

This all works fine for text fields, but one of the columns of my list is a custom field of type 'Choice', and I'd like to display that field as a SharePoint DropDownChoiceField within my SPGridView. However, whatever I do, the field comes out blank on the grid. The list items are included as part of the field definition, but I've also tried linking the field to a list with no success.

Does anyone have any examples of how to embed a DropDownChoiceField into an SPGridView?

Many thanks Gerry

related questions