Seting the drop down list with empty value in gridview

T

tinique

I have a problem, I have a gridview which contain the dropdownlist
when edit. However, some of the records do not contain any value
listed in the dsRoute and when I click the edit link, error will
prompt out. "gvddlRoute has a SelectedValue which is invalid because
it does not exist in the list of items. Parameter name:value" How can
I solve this problem????

<asp:TemplateField SortExpression="Route"
HeaderText="Route"><EditItemTemplate>
<asp:DropDownList id="gvddlRoute" runat="server"
DataValueField="route" DataTextField="route" DataSourceID="dsRoute"
SelectedValue='<%# if (Bind("Route")!=""){Bind("Route"} %>'></
asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label id="Label3" runat="server" Text='<%# Bind("Route") %>'></
asp:Label>
</ItemTemplate>
</asp:TemplateField>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top