简体   繁体   English

单击插入时,DetailsView Web控件不会更改为插入模式

[英]DetailsView web control does not change to insert mode when insert is clicked

I'm binding a hashtable to a detailsview web control in ASP.NET 2.0. 我将哈希表绑定到ASP.NET 2.0中的detailsview Web控件。 I have my edit/delete/insert link buttons on the detailsview, but when clicking new, the mode does not change. 我在DetailsView上有我的“编辑/删除/插入”链接按钮,但是单击“新建”时,模式不会改变。

Any ideas why? 有什么想法吗?

I'm assuming that you have created a 'New' Button within the DetailsView. 我假设您已在DetailsView中创建了“新建”按钮。 You should be able to simply handle the click event in your CodeBehind, and call the DetailsView.ChangeMode Method. 您应该能够简单地在CodeBehind中处理click事件,然后调用DetailsView.ChangeMode方法。

    DetailsViewName.ChangeMode(DetailsViewMode.Insert)
    DetailsViewName.DataBind()

In this case, I simply rebinded the DetailsView to show a blank form. 在这种情况下,我只是重新绑定了DetailsView以显示空白表格。 You can also use the Click event to bind controls within the DetailsView form as well. 您还可以使用Click事件来在DetailsView表单内绑定控件。

Fill out the form, click Add, and the Item_Inserting Event should get handled. 填写表单,单击“添加”,然后应该处理Item_Inserting事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM