I have problem with DropDownList template in Grid View, after I go in edit mode drop down have to be selected by current item instead of default value.
<asp:TemplateField HeaderText="Tour Type">
<EditItemTemplate>
<asp:DropDownList AppendDataBoundItems="true" DataSourceID="dropDownListSqlDataSource" runat="server" DataValueField="idTypetour" DataTextField="title"></asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<%#Eval("typeTitle")%>
</ItemTemplate>
</asp:TemplateField>
I tried to use SelectedValue=”<%#Eval(“typeTitle”)%>”, but has no results.
Try to use
Bindinstead ofEval:The DataValueField is “idTypetour” and the DataTextField is “title”, you have tried to use Eval(“typeTitle”). What column is
typeTitle? I assume that this must beidTypetourbecause you want to set the SelectedValue, what normally is the ID.Here are informatons on the differences:
http://msdn.microsoft.com/en-us/library/ms178366.aspx