I have the following code that is throwing this error but the solutions I’ve found say, "Have you tried the DataSourceID instead of DataSource?" with no indication as to what should be used for the DataSourceID value.
<Columns>
<asp:BoundColumn DataField="id" SortExpression="id" HeaderText="ID" ItemStyle-CssClass="dgCells"></asp:BoundColumn>
<asp:BoundColumn DataField="first_name" SortExpression="first_name" HeaderText="First" ItemStyle-CssClass="dgCells"></asp:BoundColumn>
<asp:BoundColumn DataField="last_name" SortExpression="last_name" HeaderText="Last" ItemStyle-CssClass="dgCells"></asp:BoundColumn>
<asp:BoundColumn DataField="login_pw" HeaderText="Password" ItemStyle-CssClass="dgCells"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Race">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "race_name") %>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList runat="server" id="ddlRaces" DataValueField="race_id" DataTextField="race_name" >>>DataSourceID=""<<< />
</EditItemTemplate>
</asp:TemplateColumn>
<asp:EditCommandColumn EditText="Edit" CancelText="Cancel" UpdateText="Ok"></asp:EditCommandColumn>
</Columns>
What I should be inserting into the DataSourceID="" value?
The
DataSourceIDshould be set to the ID of a control on your page that inherits fromDatasourceControlsuch asSqlDatasourceif you want to populate the grid from an SQL databaseTo bind the DropDown in a GridView