Reputation: 7566
I have a dropdownlist in gridview and bind grid view from a function in code behind for the dropdownlist. The problem is the dropdownlist is in edittemplate and the selected value is the id in the same celle when the is dropdownlist when the row is not editing.
How I can display in editing the null value????
Upvotes: 0
Views: 2112
Reputation: 1175
You can put Your business logic and check whether the selected value is not null and then you can use your data items that would symbolize null when selected.
<asp:DropDownList ID="ddlitems" runat="server" SelectedValue='<%# Bind("mydata") %>' AppendDataBoundItems="true">
<asp:ListItem Value="">select</asp:ListItem>
</asp:DropDownList>
Upvotes: 1
Reputation: 2101
Add an item to your dropdownlist that represent the null value.
<asp:DropDownList ID="DropDownList1" runat="server" SelectedValue='<%# Bind("CurrencyType") %>' AppendDataBoundItems="true">
<asp:ListItem Value="">Not selected</asp:ListItem>
</asp:DropDownList>
Upvotes: 2