Right now I have a Datagrid displaying some details for trailers. I want to put a DropDownList into the Datagrid so the location can be changed but I keep getting the error:
Error 32 Literal content ('') is not allowed within a 'System.Web.UI.WebControls.DataGridColumnCollection'. C:\inetpub\wwwroot\test\test\lookups\Trailer.aspx 215
I've seen code examples of of DropDownLists in datagrids before so why am I getting this error? Here's the code for the DataGrid:
<asp:DataGrid runat="server" CssClass="tblResults" OnItemDataBound="dgList_ItemCreated" AllowSorting="true" OnSortCommand="dgTrailer_Sort" ID="dgTrailers" DataKeyField="ID" AutoGenerateColumns="false">
<HeaderStyle CssClass="tblResultsHeader" />
<AlternatingItemStyle BackColor="#EEEEEE" />
<Columns>
<asp:BoundColumn DataField="TrailerMake" HeaderText="Trailer Make" SortExpression="TrailerMake"></asp:BoundColumn>
<asp:BoundColumn DataField="TrailerLocation" HeaderText="Trailer Location" SortExpression="TrailerLocation"></asp:BoundColumn>
<asp:BoundColumn DataField="Year" HeaderText="Year" SortExpression="Year"></asp:BoundColumn>
Firstly, it looks like you are missing the closing tag for Columns.
Secondly, to add a dropdownlist you would have to use asp:TemplateColumn then bind your data to that dropdownlist: