模型视图演示者 - 如何在下拉列表中显示所选项目?
我正在使用模型-视图-演示者框架。加载页面时,我在设置来自数据库的所选项目时遇到问题。
鉴于,我知道我需要:
protected void ddlStatus_SelectedIndexChanged(object sender, EventArgs e)
{
presenter.DdlStatusSelectedIndexChanged();
// what should this pass?
}
Then in Presenter:
public void DdlStatusSelectedIndexChanged()
{
view.DdlStatus = ???
// Should I pass the SelectedIndex?
}
我还认为我的部分问题是我将 DdlStatus 作为列表。 界面:
List<StatusDTO> DdlStatus { set; get; }
有人有一些简单的例子吗? 我找到的最好的就在这里(但需要格式化!)---> http://codebetter.com/blogs/jeremy。米勒/archive/2006/02/01/137457.aspx
谢谢!
I'm using Model-View-Presenter framework. When Loading a page, I'm having trouble setting the selected item that came from the Database.
In view, I know I need:
protected void ddlStatus_SelectedIndexChanged(object sender, EventArgs e)
{
presenter.DdlStatusSelectedIndexChanged();
// what should this pass?
}
Then in Presenter:
public void DdlStatusSelectedIndexChanged()
{
view.DdlStatus = ???
// Should I pass the SelectedIndex?
}
I also think that part of my problem is that DdlStatus I have as a List.
Interface:
List<StatusDTO> DdlStatus { set; get; }
Does anybody have some simple examples of this?
The best I found is here (but needs formatted!) --->
http://codebetter.com/blogs/jeremy.miller/archive/2006/02/01/137457.aspx
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您使用哪个框架?演示者/观看者关系的典型工作方式是通过事件;视图定义演示者附加的事件,以接收这些状态更改通知。还有其他选择。
您的模型应包含状态列表和所选状态。根据 MVP 的“风格”,您可以让演示者调用视图上的属性以将选定的索引传递给它,并且您的视图将其传递给控件,或者视图直接从模型获取索引。
HTH。
Which framework are you using? The typical way the presenter/view relationship works is through events; the view defines events that the presenter attaches to, to receive those state change notifications. There are other options too.
Your model should contain the list of statuses and the selected status. Depending on the "flavor" of MVP, you would either have the presenter call a property on the view to pass it the selected index, and your view would pass it to the control, or the view takes the index from the model directly.
HTH.
我明白了这一点。它有点像奶酪,但是......
I figured this out. It's a bit of a cheese but ...