2010-04-28 148 views
0

我在gridview中有一个下拉列表,并且在下拉列表的代码后面绑定了一个函数的网格视图。 问题是下拉列表位于edittemplate中,当行未编辑时,选择的值是同一个celle中的id。gridview中的dropdownlist空值

如何在编辑空值时显示?

回答

2

向您的下拉列表中添加一项代表空值的项目。

<asp:DropDownList ID="DropDownList1" runat="server" SelectedValue='<%# Bind("CurrencyType") %>' AppendDataBoundItems="true"> 
      <asp:ListItem Value="">Not selected</asp:ListItem> 
      </asp:DropDownList> 
2

你可以把你的业务逻辑,并检查所选值是否不为空,然后你可以使用选择时,将象征着空的数据项。

<asp:DropDownList ID="ddlitems" runat="server" SelectedValue='<%# Bind("mydata") %>' AppendDataBoundItems="true"> 
<asp:ListItem Value="">select</asp:ListItem> 
</asp:DropDownList> 
相关问题