0

I have a GridView which displays some data from list of objects using BoundField columns.

<asp:GridView ID="UserGridView" runat="server"
            ItemType="User" DataKeyNames="Login" SelectMethod="GetUsers"
            UpdateMethod="UserGridView_UpdateItem"
 AutoGenerateColumns="False">
            <Columns>
                <asp:CommandField ButtonType="Image" ShowEditButton="True" CancelImageUrl="~/Content/cancel.png" DeleteImageUrl="~/Content/trash.png" EditImageUrl="~/Content/edit.png" UpdateImageUrl="~/Content/edit.png" />
                <asp:BoundField DataField="Id" ReadOnly="true" HeaderText="User Id" />
                <asp:BoundField DataField="Login" HeaderText="Login" />
                <asp:BoundField DataField="Profile" HeaderText="Profile" />
            </Columns>
        </asp:GridView>

In my case, field Profile can take on of 3 predefined values - "admin", "customer", "salesperson". So I want I would be able to select on of this values from DropDownList when GridView is in Edit mode. Can anyone help me?

Denis_Sh
  • 307
  • 3
  • 7
  • 16

1 Answers1

3

replace: <asp:BoundField DataField="Profile" HeaderText="Profile" />

<asp:TemplateField HeaderText = "Profile">
            <ItemTemplate>
                <asp:Label ID="Profile" runat="server" Text='<%# Eval("Profile") %>' Visible = "false" />
                <asp:DropDownList ID="ddlProfile" runat="server">
                </asp:DropDownList>
            </ItemTemplate>
        </asp:TemplateField>
redIntent
  • 134
  • 5