I am trying to add a column with dropdownlist to a DataGrid
Here is the code for the DataGrid binding datasource
List<CPDEmployee> employeelist = (List<CPDEmployee>)Cache["EmployeeList"];
unverifiedlist.DataSource = employeelist;
unverifiedlist.DataBind();
unverifiedlist.AllowPaging = true;
unverifiedlist.PageSize = 10;
In the page.aspx code is like this
<asp:DataGrid ID="unverifiedlist" runat="server" AllowPaging="true" PageSize="10" OnPageIndexChanged="unverifiedlist_PageIndexChanged">
<Columns>
<asp:BoundColumn HeaderText="Surname" DataField="Surname" ReadOnly="true">
</asp:BoundColumn>
</Columns>
<Columns>
<asp:TemplateColumn HeaderText="Options" >
<ItemTemplate>
<asp:DropDownList ID="options" runat="server">
<asp:ListItem Value="1">Verified</asp:ListItem>
<asp:ListItem Value="0">Rejected</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText ="Reason">
<ItemTemplate>
<asp:TextBox ID="reason" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>

The result is there are two "Surname" fields in the datagrid. The reason I added "Surname" from page side is that i can’t set the order of the columns (the dropdownlist should be at last).
Does anyone know how to solve this problem? thanks very much
You have to turn off AutoGenerateColumns and specify all the bound fields.