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

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top