【问题标题】:DropdownList in Gridview not saving valuesGridview中的DropdownList不保存值
【发布时间】:2014-02-20 23:48:08
【问题描述】:

我有一个gridview,在编辑模式下在一列中有一个下拉列表 问题是我无法在编辑后保存选定的值,当我按下编辑时我可以显示字段中的数据。 我展示了一些执行 SelectedValue='' 的示例,但 SelectedValue 无法识别。 页面是

    <asp:TemplateField HeaderText="Category" SortExpression="Category">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList1" runat="server" DataTextField="Category" >
                        <asp:ListItem>1</asp:ListItem>
                        <asp:ListItem>2</asp:ListItem>
                        <asp:ListItem>3</asp:ListItem>
                        <asp:ListItem>4</asp:ListItem>
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Category") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>

当我使用文本框而不是 dtopdown 时,编辑后的值会正确保存 有什么想法吗?

【问题讨论】:

标签: asp.net gridview


【解决方案1】:

我终于找到了解决问题的方法。

在模板字段中,我选择了编辑数据绑定,然后在 SelectedValue 中,我选择了自定义绑定并放入 Bind("category")

现在可以了

【讨论】:

  • 如果您找到解决方案,最好放置代码示例
猜你喜欢
  • 2016-10-30
  • 2021-11-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-30
  • 2014-01-11
相关资源
最近更新 更多