开发者

dropdownlist in gridview null value

I 开发者_StackOverflowhave 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????


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>


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜