MVP上Asp.Net的WebForms [英] MVP on Asp.Net WebForms

查看:142
本文介绍了MVP上Asp.Net的WebForms的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我并不清楚这一点......

I'm not clear about this....

在观看具有gridview的时候,是谁拥有设置数据源,列等的控制?或者我只是揭露数据绑定的东西,从控制器火了,让HTML / codebehind在视图处理所有的渲染和布线呢?

When having a gridview on the View, is the controller who has to set up the Data source, columns, etc? or I just have to expose the DataBinding stuff, fire it from the controller and let the html/codebehind on the view handle all the rendering and wiring up?

要更precise:在查看我应该有

To be more precise: on the view should I have

private GridView _gv
public _IList<Poco> Source { 
    get {_gv.DataSource;}
    set {_gv.DataSource = value;
         _gv.DataBind();}
}

还是应(从<一个href=\"http://stackoverflow.com/questions/153222/mvp-pattern-passive-view-and-exposing-complex-types-through-iview-asp-net-web\">http://stackoverflow.com/questions/153222/mvp-pattern-passive-view-and-exposing-complex-types-through-iview-asp-net-web)

private GridView _datasource;
public DataSource 
{
  get { return _datasource; }
  set 
  { 
    _datasource = value; 
    _datasource.DataBind(); 
  }
}

也许我把头发全都错了....

Maybe I'm having it all wrong ....

我在哪里可以找到一个例子,是不是一个Hello World的例子在MVP的ASP.Net ???

Where can I find an example that is not a "Hello world" example on MVP for ASP.Net???

推荐答案

您控制器应负责设定数据绑定的结果的。视图负责propertly显示出来的。

Your controller should be in charge of setting the "result" of the databinding. The view is in charge of displaying it propertly.

因此​​,例如,您的表单/用户控件(视图)可能有暴露作为对象属性的数据源,你应该查看知道如何处理,当它接收它:

So for example, your webform/usercontrol (View) could have the data source exposed as an object property that your View should know how to handle when it receives it:

public MyObject DataSource 
{
  set 
  { 
    _datasource = value; 
    _datasource.DataBind(); 
  } 
}

所以,如果你需要有一个ItemDataBound事件,我仍然会处理它在视图中。即使有可能在事件的业务逻辑。如果你需要有业务逻辑的情况下,我会把它在为MyObject结果它被传递给视图前。

So if you need to have an ItemDataBound event, I would still handle it in the view. Even though there could be business logic in the event. If you need to have business logic in the event, I would put it in the MyObject result before it is passed to the view.

因此​​,一个例子是有被AllowDelete,并在你的ItemDataBound,这个属性的值决定,如果在GridView一列被启用。的MyObject来的属性。

So an example would be to have a property of "MyObject" be "AllowDelete" and in your ItemDataBound, the value of this property determines if a column in the GridView is enabled or not.

这篇关于MVP上Asp.Net的WebForms的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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