Error while adding child template to Master Template

3 posts, 0 answers
  1. Subramanya
    Subramanya avatar
    3 posts
    Member since:
    Oct 2015

    Posted 21 May Link to this post

         I am getting a Object variable not set error while adding a child template to master template of grid view

    here is my code

                {
                    grddisplaygrid.DataSource = (DataTable)TransactionController.FetchObject("Itemdetails");
                }

               
               GridViewMultiComboBoxColumn tempmulticombo = (GridViewMultiComboBoxColumn)grddisplaygrid.Columns["BatchNo"];
                tempmulticombo.HeaderText = TransactionController.g_strbatchCaption == "" ? tempmulticombo.HeaderText : TransactionController.g_strbatchCaption;
                tempmulticombo = (GridViewMultiComboBoxColumn)grddisplaygrid.Columns["StockNo"];
                tempmulticombo.HeaderText = TransactionController.g_strStockNoCaption == "" ? tempmulticombo.HeaderText : TransactionController.g_strStockNoCaption;
                GridViewComboBoxColumn tempcombo = (GridViewComboBoxColumn)grddisplaygrid.Columns["SMGUid"];
                tempcombo.IsVisible = false;
                tempcombo = (GridViewComboBoxColumn)grddisplaygrid.Columns["UOM"];
                DataTable dttemp = GetUOmlist();
                tempcombo.DataSource = dttemp;
                tempcombo.DisplayMember = "UnitSymbol";
                tempcombo.ValueMember = "QBGUID";
                tempcombo.DropDownStyle = RadDropDownStyle.DropDownList;
                tempcombo.AutoCompleteMode = AutoCompleteMode.Suggest;
                #region item level Location
                if (TransactionController.g_intLocationenabled == 3)
                {
                    tempmulticombo = (GridViewMultiComboBoxColumn)grddisplaygrid.Columns["LocationCd"];
                    tempmulticombo.IsVisible = true;
                    tempmulticombo.Width = 100;
                    tempmulticombo.ReadOnly = false;
                    tempmulticombo.HeaderText = TransactionController.g_strlocationCaption == "" ? tempmulticombo.HeaderText : TransactionController.g_strlocationCaption;
                }
                #endregion item level Location

                OverrideColumnVisibility();
                if (TransactionController.g_intDisplayImageinItemDisplaygrid > 0)
                {
                    GridViewImageColumn colimage = (GridViewImageColumn)grddisplaygrid.Columns["ItemImage"];
                    colimage.IsVisible = true;
                }
                templatesubdetails = new GridViewTemplate();
                templatesubdetails.AllowAddNewRow = false;
                templatesubdetails.AllowEditRow = false;
                templatesubdetails.AllowDeleteRow = false;
                templatesubdetails.ShowRowHeaderColumn = false;
                if (dtsubitemdetails.Columns.Count > 0) { dtsubitemdetails.Columns.Clear(); }
                dtsubitemdetails.Columns.Add("cStockNo", typeof(string));
                dtsubitemdetails.Columns.Add("cItemDesc", typeof(string));
                dtsubitemdetails.Columns.Add("cBatchNo", typeof(string));
                dtsubitemdetails.Columns.Add("cQty", typeof(decimal));
                dtsubitemdetails.Columns.Add("cUOM", typeof(string));
                dtsubitemdetails.Columns.Add("cItemGUID", typeof(string));
                dtsubitemdetails.Columns.Add("cBatchGuid", typeof(string));
                dtsubitemdetails.Columns.Add("cBOMItemGuid", typeof(string));
                dtsubitemdetails.Columns.Add("cRowsrlno", typeof(int));
                dtsubitemdetails.Columns.Add("cBOMQty", typeof(decimal));
                dtsubitemdetails.Columns.Add("BatchEnabled", typeof(int));
                dtsubitemdetails.Rows.Clear();
                templatesubdetails.DataSource = dtsubitemdetails;

                templatesubdetails.Columns["cItemGUID"].IsVisible = false;
                templatesubdetails.Columns["cRowsrlno"].IsVisible = false;
                templatesubdetails.Columns["cBOMQty"].IsVisible = false;
                templatesubdetails.Columns["cBatchGuid"].IsVisible = false;
                templatesubdetails.Columns["cBOMItemGuid"].IsVisible = false;
                templatesubdetails.Columns["BatchEnabled"].IsVisible = false;
                templatesubdetails.Columns["cStockNo"].HeaderText = "Stock No.";
                templatesubdetails.Columns["cStockNo"].Width = 100;
                templatesubdetails.Columns["cItemDesc"].HeaderText = "Description";
                templatesubdetails.Columns["cItemDesc"].Width = 120;

                templatesubdetails.Columns["cBatchNo"].HeaderText = "Batch Number";
                templatesubdetails.Columns["cBatchNo"].Width = 100;
                templatesubdetails.Columns["cBatchNo"].IsVisible = TransactionController.g_intbatchEnabled > 0 ? true : false;

                GridViewDecimalColumn deccolumn = (GridViewDecimalColumn) templatesubdetails.Columns["cQty"];
                deccolumn.HeaderText = "Qty.";
                deccolumn.Width = 70;
                deccolumn.DecimalPlaces = 3;
                deccolumn.FormatString = "{0:N3}";

                templatesubdetails.Columns["cUOM"].HeaderText = "Per";
                templatesubdetails.Columns["cUOM"].Width = 80;
                grddisplaygrid.MasterTemplate.Templates.Clear();
                grddisplaygrid.Relations.Clear();
               
                
               grddisplaygrid.MasterTemplate.Templates.Add(templatesubdetails);

     

    getting the error while executing the above line of code. kindly help me to solve the issue.

               

  2. Subramanya
    Subramanya avatar
    3 posts
    Member since:
    Oct 2015

    Posted 22 May in reply to Subramanya Link to this post

    The Issue has been resolved .actually the issue because i haven't initialized the object properly. 
  3. Nadya
    Admin
    Nadya avatar
    341 posts

    Posted 22 May Link to this post

    Hello Subramanya,

    I am glad that you managed to resolve the problem that you had. Do not hesitate to contact us if you have any other questions.

    Regards,
    Nadya
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top