使用MVC和Win Forms背景学习ASP.NET Webforms
好吧,这会很奇怪,但我的上一个项目是所有ASP.NETMVC3、WCF/REST/SOAP和WinForms以及WPF 我知道HTTP是无状态的,我开始对Web窗体在幕后关于Web控件所做的伏都教感到奇怪。事实上,我正在努力将我的思想包装在数据绑定上。显然,它与Win Forms数据绑定技术非常不同使用MVC和Win Forms背景学习ASP.NET Webforms,asp.net,webforms,Asp.net,Webforms,好吧,这会很奇怪,但我的上一个项目是所有ASP.NETMVC3、WCF/REST/SOAP和WinForms以及WPF 我知道HTTP是无状态的,我开始对Web窗体在幕后关于Web控件所做的伏都教感到奇怪。事实上,我正在努力将我的思想包装在数据绑定上。显然,它与Win Forms数据绑定技术非常不同 有没有好的模式和示例可以解释数据绑定和Web控件的实际情况?当我为Win Forms编程时,我似乎一直将其视为不断绑定到某个数据源 看一看。根据记忆,那里的文章相当全面。你首先应该了解的是。一旦你了
有没有好的模式和示例可以解释数据绑定和Web控件的实际情况?当我为Win Forms编程时,我似乎一直将其视为不断绑定到某个数据源 看一看。根据记忆,那里的文章相当全面。你首先应该了解的是。一旦你了解了这一点,你就会开始理解web表单的机制。它可能看起来很神奇,因为它已经融入到建筑中,但一旦你理解了它,它就变得非常简单
/// <summary>
/// Binds the data source to the control.
/// </summary>
public override void DataBind()
{
this.PerformSelect();
}
/// <summary>
/// Retrieves data from the associated data source.
/// </summary>
protected override void PerformSelect()
{
//if the control is bound from a datasource control then
//fire the ondatabinding event
if (!this.IsBoundUsingDataSourceID)
this.OnDataBinding(EventArgs.Empty);
//retrive the data source view object and bind the data to the control
this.GetData().Select(CreateDataSourceSelectArguments(), PerformDataBinding);
//mark that the control has been bound to the source
this.RequiresDataBinding = false;
this.MarkAsDataBound();
//fire the on data bound event so it can be
//handled from the parent object
this.OnDataBound(EventArgs.Empty);
}
/// <summary>
/// Binds data from the data source to the control.
/// </summary>
/// <param name="retrievedData"></param>
protected override void PerformDataBinding(IEnumerable retrievedData)
{
//call the base method
base.PerformDataBinding(retrievedData);
//clear all controls and viewstate data and reset
//the viewstate tracking mechanism
this.Controls.Clear();
this.ClearChildViewState();
this.TrackViewState();
//generate all child controls within the hierarchy
this.CreateControlHierarchy(true, retrievedData);
//mark child controls created as true
this.ChildControlsCreated = true;
}
我想这是我应该走的路。我对来自客户端和mvc端编程的Web表单的异教方式感到非常困惑。我想知道是否有一个具有良好模式和实践的好网站可以帮助我进一步理解它。
//assign the datasource to the control
GridView1.DataSource = new DataTable("DataSource");
//bind the datasource to the control
GridView1.DataBind();