Wednesday, August 29, 2012

levels in component art grid in asp.net using c#.net

 if (!Page.IsPostBack)
            {
  buildTopLevel();
                        grdGroups.DataBind();
}   
 private void buildTopLevel()
        {
            if (Session["UserName"] != null)
            {
                DataSet ds = new DataSet();
                List<GroupDO> objListGroupDO = new List<GroupDO>();
                ObjGroupDO.AccountID = Convert.ToInt64(Session["AccountID"]);
                ObjGroupDO.UEmail = Session["UserName"].ToString();
                objListGroupDO = Activayt.Business.Group.SelectGroups(ObjGroupDO.AccountID, ObjGroupDO.UEmail);
                ds = ConvertListToDataSet(objListGroupDO);
                grdGroups.DataSource = ds;
            }
       
        }
 public void OnNeedRebind(object sender, EventArgs oArgs)
        {
            grdGroups.DataBind();
        }
        public void OnNeedDataSource(object sender, EventArgs oArgs)
        {
            buildTopLevel();
        }
        public void OnNeedChildData(object sender, ComponentArt.Web.UI.GridNeedChildDataSourceEventArgs args)
        {
            ObjGroupDO.UEmail = Session["UserName"].ToString();
            ObjGroupDO.AccountID =Convert.ToInt64(Session["AccountID"]);
            List<GroupDO> objListGroups=Group.SelectAll(ObjGroupDO.AccountID,ObjGroupDO.UEmail);
            DataSet ds = ConvertListToDataSet(objListGroups);
            if (args.Item.Level == 0)
            {
                DataView dv = ds.Tables[0].DefaultView;
                dv.RowFilter = "ParentGroupID=" + args.Item["GroupID"];
                args.DataSource = dv.ToTable();
            }
            else if (args.Item.Level == 1)
            {
                DataView dv = ds.Tables[0].DefaultView;
                dv.RowFilter = "ParentGroupID=" + args.Item["GroupID"];
                args.DataSource = dv.ToTable();
            }
        }
        #region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
        {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
            base.OnInit(e);
        }
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.Load += new System.EventHandler(this.Page_Load);
            grdGroups.NeedRebind += new ComponentArt.Web.UI.Grid.NeedRebindEventHandler(OnNeedRebind);
            grdGroups.NeedDataSource += new ComponentArt.Web.UI.Grid.NeedDataSourceEventHandler(OnNeedDataSource);
            grdGroups.NeedChildDataSource += new ComponentArt.Web.UI.Grid.NeedChildDataSourceEventHandler(OnNeedChildData);

        }
        #endregion

No comments:

Post a Comment