Click here to Skip to main content
15,892,737 members
Articles / Web Development / ASP.NET

Master Pages and Factory Pattern

Rate me:
Please Sign up or sign in to vote.
4.35/5 (16 votes)
17 Jan 2007CPOL6 min read 66.2K   792   50  
Master pages and factory patterns using ASP.NET
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// This will control the opertaion when user selects OrderDetail from the menu
/// </summary>
public class BIOrderMaster : Base
{
    private DAccessOrder Orders = new DAccessOrder();
    private DataSet dsParent = new DataSet();


    public BIOrderMaster()
	{
        dsParent = Orders.getOrders();

	}

    public override void BindParentGrid(DataDigest.WebControls.GridView gvParent)
    {
        if (dsParent == null)
        {
            dsParent = Orders.getOrders();
        }
        string[] key = new string[1];
        key[0] = "OrderID";
        gvParent.DataSource = null;
        gvParent.Columns.Clear();
        //if (dsParent.Tables["TtlCoGeneral"].Rows.Count == 0)
        //{
        //    AddDummyData(dsParent);
        //}
        gvParent.DataSource = dsParent;
        gvParent.DataKeyNames = key;
        BoundField TtlCoNm = new BoundField();
        TtlCoNm.DataField = "OrderID";
        TtlCoNm.HeaderText = "Order ID";
        gvParent.Columns.Add(TtlCoNm);
        TtlCoNm.ItemStyle.Width = 600;

        gvParent.DataBind();
    }

    public override void BindChildGrid(DataDigest.WebControls.GridView gvChild, string ParentId)
    {
        string[] key = new string[1];
        key[0] = "ProductID";

        DataSet dsChild = Orders.getProducts(ParentId);
        gvChild.SelectedIndex = -1;
        gvChild.DataSource = null;
        gvChild.Columns.Clear();
        //if (dsBranch.Tables["TtlCoBranch"].Rows.Count == 0)
        //{
        //    AddDummyData(dsBranch);
        //}
        gvChild.DataSource = dsChild;
        gvChild.DataKeyNames = key;
        BoundField BrName = new BoundField();
        BrName.DataField = "ProductName";
        BrName.HeaderText = "Product Name";
        gvChild.Columns.Add(BrName);
        BrName.ItemStyle.Width = 600;
        gvChild.DataBind();
    }

    public override DataSet getParentData()
    {
        return dsParent;
    }

    public override DataSet getChildData(string Key)
    {
        return Orders.getProducts(Key);
    }

    //private void AddDummyData(DataSet ds)
    //{
    //    // Add a dummy row
    //    DataTable dt = ds.Tables[0];
    //    DataRow newRow = dt.NewRow();
    //    dt.Rows.Add(newRow);

    //}


}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Systems Limited
Pakistan Pakistan
I have graduated from SirSyed university of engineering and technology in year 2005. Working on Microsoft Platform for 3 years.
I like to work on new technologies. Always keen to learn new orientation in software design. Design patterns is the area for which i am looking to work on.

Comments and Discussions