I had to make few pages that display different data. One had to display Articles and the other one had to display code samples. Both of them contained the datagrid and had the capability of sending the links of the articles. At first I coded the datagrid inside the webform. But than I see that the code is repeating all the time so decided to choose user controls. This simplified the development and also kept the code easy to modify.
Now in the webform code behind I just have to make the object of the "UserControl" and bind it to the screen. Any change in the UserControl will trigger the change in the Webform that uses that control.
The Code Behind of the Webform Page:
components.Articles articles = new AzamSharpPortal.components.Articles();
ItemList myControl = (ItemList) FindControl("ItemList1");
DataGrid dg = (DataGrid) myControl.FindControl("myDataGrid");
dg.DataSource = articles.GetAllArticles();
dg.DataBind();
1 comment:
Just blogging for a while, my site is also about cheap asp hosting, so just saying hi.
Charles
Post a Comment