如何在后面的代码中检查fromview的当前视图模式

时间:2014-08-08 08:42:47

标签: c# asp.net formview

我想检查FormView当前模式是否为只读,以便我可以运行一些代码。我怎样才能做到这一点?谢谢。

 protected void FormView_DataBound(object sender, EventArgs e)
{
 //Here I want to add codes only if the current view of the Formview is read only (neither insert nor edit modes).
{

2 个答案:

答案 0 :(得分:0)

您可以检查FormView是否在FormViewMode.ReadOnly中。

检查此artice - http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.formview.currentmode(v=vs.110).aspx

protected void FormView_DataBound(object sender, EventArgs e)
{    
//Here I want to add codes only if the current view of the Formview is read only (neither insert nor edit modes).
   if (FormView.CurrentMode == FormViewMode.ReadOnly)
   {
   }
}

答案 1 :(得分:0)

取自:FormView.CurrentMode Property

protected void FormView_DataBound(object sender, EventArgs e)
{    
   if (FormView.CurrentMode == FormViewMode.ReadOnly)
   {
   }
}