除非所有字段都存在,否则“详细信息视图更新”命令不会更新!

发布于 2024-10-02 17:23:03 字数 252 浏览 0 评论 0原文

我有一个页面将数据从数据库绑定到详细信息视图。

我想使用自动生成的更新命令。

一切顺利,更新也成功,但如果我删除任何我不想有机会更新的字段,则更新命令不会更新!旧价值观保留!

我的意思是:如果所有字段都存在于详细信息视图中,则更新将正常,否则,更新将不会更新任何内容。

我尝试将我不想查看的字段标记为“Visible = 'false'”,但没有好的结果!

我怎样才能隐藏一些字段?

谢谢 :)

I have a page that binds data from DB to a DetailsView.

I want to use the auto-generated Update command.

Everything went OK, and also updating was successful, but if I remove any field that I don't want to have chance to update, then the Update command doesn't update! the old values retain!

I mean: if all of the fields are present in the detailsView, the update will be OK, otherwise, the update will NOT update any thing.

I've tried to mark the fields that I don't want to view as "Visible = 'false'" but with no good results!

How could I hide some fields?

Thanks :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不知所踪 2024-10-09 17:23:03

您是否尝试将不想更新的字段也设置为“ReadOnly = True”?这应该将它们标记为不更新。

Did you try to put the field you don't want to update at 'ReadOnly = True' too? This should mark them as to not be updated.

陪我终i 2024-10-09 17:23:03

这是一种方法。

protected void DetailsView1_ModeChanged(object sender, EventArgs e)
{
    if (DetailsView1.CurrentMode == DetailsViewMode.Edit)
    {
        foreach (DataControlField fd in DetailsView1.Fields)
        {
            BoundField tmp = fd as BoundField;
            if (tmp != null)
                if (tmp.DataField == "YourReadOnlyColumnName")
                    tmp.ReadOnly = true;
        }

    }
}

Here is a way of doing it..

protected void DetailsView1_ModeChanged(object sender, EventArgs e)
{
    if (DetailsView1.CurrentMode == DetailsViewMode.Edit)
    {
        foreach (DataControlField fd in DetailsView1.Fields)
        {
            BoundField tmp = fd as BoundField;
            if (tmp != null)
                if (tmp.DataField == "YourReadOnlyColumnName")
                    tmp.ReadOnly = true;
        }

    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文