Harold Sota
Harold Sota

Reputation: 7566

dropdownlist in gridview null value

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

Answers (2)

Ashish Babu
Ashish Babu

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

alejandrobog
alejandrobog

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

Related Questions