Here, I have a DropDownList in the EditItemTemplate:
<asp:TemplateField HeaderText="RequestedBy" SortExpression="RequestedBy">
<EditItemTemplate>
<asp:DropDownList ID="ReqUserDDL" runat="server" AppendDataBoundItems ="True" DataSourceID="ReqUsersDataS" DataTextField="Name" DataValueField="Name" SelectedValue='<%# Bind("Name") %>' >
</asp:DropDownList>
<asp:SqlDataSource ID="ReqUsersDataS" runat="server" ConnectionString="<%$ ConnectionStrings:itassetmgmtConnectionString1 %>" SelectCommand="SELECT Firstname + Lastname AS Name FROM Users"></asp:SqlDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label7" runat="server" Text='<%# Eval("RequestedBy") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
However, I keep getting this error:
DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Name'.
Is there a way to remedy this?
Use
Evalinstead ofBind.Bindis for read and/or write,Evalis read-only.EDIT: Eval/Bind error is not from from the ReqUsersDataS DataSource. It is trying to for a column named 'Name' on the data source of the GridView that has the TemplateField you showed. You just need to make sure that other data source has column named 'Name'.