DetailsView是魔鬼吗? [英] DetailsView is the Devil?

查看:72
本文介绍了DetailsView是魔鬼吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我的朋友们.
我即将得出的结论是,DetailsView的要么是魔鬼,只是不喜欢游泳我! :)

背景故事:
1.这是使用ASP.NET web应用程序C#
2.我没有使用SQL数据源,,我使用Web服务调用
经由对象集合填充数据.


这是我的问题,

我有一个Detailsview,用于显示数据以及允许用户编辑和/或插入新记录.

一切都建立了,并且一切工作...所以问题是什么?

这-最初显示detailsview时,它处于ReadOnly模式.这意味着在底部,我的命令按钮编辑"和新"
这些是编辑所显示的当前记录或插入新记录.

当我第一次单击编辑"时,什么都没有发生!如果我点击编辑"第二次,它工作正常!
每次单击,即使是第一次单击,新建"按钮都可以正常工作.

我到处都看了,找不到解决办法!

如果任何人有遇到了这个,请,请,请让我知道你如何能够解决这一问题.

谢谢!

谢谢您的回复.
我想我应该对此提供更好的信息.
这是发生什么事,
第一次被点击,它确实击中了ModeChanging事件在我的代码,它只是那并不切换到编辑模式.它被点击第二次,它切换到编辑模式. - 没有错误抛出
. 这是我的代码:
< ASP:的DetailsView ID = DV" RUNAT = 服务器"
宽度="500px"
AllowPaging = 假"
AutoGenerateEditButton ="true"
AutoGenerateRows = 假"
AutoGenerateInsertButton = 假"
边框样式= 无"
网格线= 水平"
DataKeyNames ="ID"
OnDataBound ="dv_OnDataBound"
OnModeChanging ="dv_ModeChanging"
OnItemUpdating = dv_ItemUpdating"
OnItemUpdated ="dv_ItemUpdated">
<字段>
......一些领域
</字段>
</asp:DetailsView>
保护无效dv_ModeChanging(对象发件人,DetailsViewModeEventArgs E)
{
dv.ChangeMode(e.NewMode);
//看看我们是否需要重新绑定的详细信息视图
如果(e.NewMode == DetailsViewMode.ReadOnly)
this.BindDetails();
}

再次感谢

解决方案
有一些问题,只有你的代码.不知怎的,你的第一个编辑事件被取消或不提高.

尝试发现,VS的使用调试器(也使所有的例外).如果不能,邮政必要的一段代码这里.

Ok my friends.
I am about to come to the conclusion that the detailsview is either the devil, or just doesn''t like me! :)

Backstory:
1. This is an ASP.NET web application using C#
2. I am not using sql datasource,, I am using a web service call
that populates the data via an object collection.


Here is my issue,

I have a detailsview that I am using to display data, as well as allow the user to edit and/or insert new records.

Everything is set up, and everything is working... so what is the issue?

This -- When the detailsview is initially displayed, it is in ReadOnly mode. This means at the bottom, my command buttons are "Edit" and "New"
These are to edit the current record shown, or insert a new record.

When I click on "Edit" for the first time, NOTHING Happens! If I click "Edit" a second time, it works fine!
The "New" button works fine, on any click, even the first.

I have looked everywhere and I cannot find a solution for this!

If anyone has ran into this, please, please, please let me know how you were able to resolve this.

Thank you!

Thank you for your response.
I suppose I should have given better information on this.
Here is what happens,
The first time it is clicked, it does hit the ModeChanging Event in my code, it just doesn''t switch over to Edit mode. The second time it is clicked, it does switch to edit mode. - no errors are thrown.
Here is my code:
<asp:DetailsView ID="dv" runat="server"
Width="500px"
AllowPaging="false"
AutoGenerateEditButton="true"
AutoGenerateRows="false"
AutoGenerateInsertButton="false"
BorderStyle="None"
GridLines="Horizontal"
DataKeyNames="ID"
OnDataBound="dv_OnDataBound"
OnModeChanging="dv_ModeChanging"
OnItemUpdating="dv_ItemUpdating"
OnItemUpdated="dv_ItemUpdated" >
<Fields>
...some fields
</Fields>
</asp:DetailsView>
protected void dv_ModeChanging(object sender, DetailsViewModeEventArgs e)
{
dv.ChangeMode(e.NewMode);
//see if we need to rebind the details view
if (e.NewMode == DetailsViewMode.ReadOnly)
this.BindDetails();
}

Thanks again

解决方案

There is some issue with your code only. Somehow your first edit event is cancelled or not raised.

Try to find that, use debugger of VS(also enable all exceptions). If not able to, Post the necessary piece of code here.


这篇关于DetailsView是魔鬼吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆