我有一些代码为我的FormView触发DataBound事件。不幸的是(对于我在做的事情,无论如何),无论是第一次渲染页面还是单击了“编辑”,它都会引发相同的问题。如果它在ItemTemplate
和EditItemTemplate
之间运行,我需要它做不同的事情。迄今为止,我对这个主题的搜索没有结果。有没有一种简单的方法可以沿着if(IsEditItemTemplate)
的方向做点什么?有没有办法告诉我的FormView是否处于编辑模式?
1
A
回答
1
FormView.CurrentMode
是你的朋友
更多解释here
从报价网站:
Mode Description FormViewMode.Edit The FormView control is in edit mode, which allows the user to update the values of a record. FormViewMode.Insert The FormView control is in insert mode, which allows the user to add a new record to the data source. FormViewMode.ReadOnly The FormView control is in read-only mode, which is the normal display mode.
示例代码
void EmployeeFormView_OnPageIndexChanging(Object sender, FormViewPageEventArgs e)
{
// Cancel the paging operation if the user attempts to navigate
// to another record while the FormView control is in edit mode.
if (EmployeeFormView.CurrentMode == FormViewMode.Edit)
{
e.Cancel = true;
MessageLabel.Text =
"Please complete the update before navigating to another record.";
}
}
0
更好地利用合适的功能:
Private Sub EmployeeFormView_ModeChanged(sender As Object, e As EventArgs)
Handles EmployeeFormView.ModeChanged
相关问题
- 1. 有没有办法检测iPhone是否处于反色模式?
- 2. 有没有办法告诉GUICtrlCreateInput是否在其中有文字?
- 3. 有没有办法告诉JFrame是否“最大化”(MS Windows)
- 4. 有没有办法通过REST告诉Azure VM是否启动?
- 5. 告诉我们,我们是否处于调试模式
- 6. 有没有办法告诉Bitmap是否已经在Android上完全处置?
- 7. 有没有办法告诉Microsoft Office文件是否为Open XML格式?
- 8. 有没有办法告诉PHP脚本是否没有被修改?
- 9. 有没有办法告诉我们是否在构造函数中被调用?
- 10. 有没有办法告诉如果Android设备是只有wifi?
- 11. 有没有办法告诉我的UIView从哪个nib醒来?
- 12. 有没有办法告诉JVM在处理之前优化我的代码?
- 13. 有没有办法告诉子程序是否有运行时日志(n)?
- 14. 有没有办法告诉程序是否仍在运行一个方法?
- 15. 有没有办法以编程方式告诉设备的VM预算?
- 16. 有没有办法测试我是否处于信号处理程序中?
- 17. 有没有办法检查Ektron是否在我的代码隐藏中以编辑模式加载页面? (C#)
- 18. 有没有办法用C#编辑pdf?
- 19. 有没有办法告诉HtmlUnit抓住所有依赖
- 20. 有没有办法告诉Doxygen忽略(所有)命名空间?
- 21. 有没有办法告诉GCC参数的范围?
- 22. 有没有办法告诉MainMenu的宽度?
- 23. 有没有办法告诉gvim的实例,而不使用--servername?
- 24. 有没有办法告诉你的python文件在哪里?
- 25. grails - 告诉我是否有脏东西?
- 26. 有没有办法告诉eclipse在运行或调试时保存所有打开的编辑器?
- 27. 有没有办法告诉Eclipse如何解决模糊的java名称?
- 28. 有没有办法告诉哪个JavaScript文件包含事件处理程序?
- 29. 我可以告诉一个表单是否是模板中的“编辑”表单?
- 30. 有没有告诉Android设备是否是双核的API?
巨大+1(你的问题)返回到这个问题,并更新了答案。说真的,我们需要更多像你这样的人。保持! –