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.