I am having an issue with programmatically hiding and showing command item settings. Below is the code I am using. The problematic item is the ShowToExportToCsvButton. The goal is that if there are no items then I do not want to show the export to csv button. If there are then show it. The problem is that whichever comes first then that is how it stays. For example if there not records then it does not show and no matter if it does get records in a refresh the button will still not show despite the code setting it to true. Also, if I put in the html markup to show it then it always shows up and I cannot hide it. I am using an ajaxified grid. I am doing this in VS Studio 2010 using 3.5 as the target with RadControls Q1 2010 NET35 v. 2010.1.415.35. Its worth noting that this same thing happens if I try to hide and show the footer with similar code. Is there another place in the process of the grid I should be doing this?
protected void rgForecastSummaryView_Values_DataBound(object sender, EventArgs e) |
{ |
if (rgForecastSummaryView_Values.Items.Count > 0) |
{ |
GridFooterItem footerItem = (GridFooterItem)rgForecastSummaryView_Values.MasterTableView.GetItems(GridItemType.Footer)[0]; |
footerItem["MaterialGroup"].Text = "Grand Totals:"; |
footerItem["MaterialGroup"].Font.Bold = true; |
footerItem["PriorYear"].Text = priorYearTotal.ToString(); |
footerItem["PriorPeriod"].Text = priorPeriodTotal.ToString(); |
footerItem["AccRepForecast"].Text = accountForecastTotal.ToString(); |
footerItem["MgmtAllocation"].Text = managmentAllocationTotal.ToString(); |
footerItem["Difference"].Text = differenceTotal.ToString(); |
rgForecastSummaryView_Values.ShowGroupPanel = true; |
rgForecastSummaryView_Values.MasterTableView.CommandItemSettings.ShowExportToCsvButton = true; |
GridCommandItem commandItem = (GridCommandItem)rgForecastSummaryView_Values.MasterTableView.GetItems(GridItemType.CommandItem)[0]; |
LinkButton lnkbtn1 = (LinkButton)commandItem.FindControlRecursive("InitInsertButton"); |
lnkbtn1.Visible = true; |
ramForecastSummaryView_AjaxManager.AjaxSettings.AddAjaxSetting(lnkbtn1, rgForecastSummaryView_Totals, ralpForecastSummaryView_LoadingPanel); |
ramForecastSummaryView_AjaxManager.AjaxSettings.AddAjaxSetting(lnkbtn1, rgForecastSummaryView_Values, ralpForecastSummaryView_LoadingPanel); |
} |
else |
{ |
rgForecastSummaryView_Values.ShowGroupPanel = false; |
rgForecastSummaryView_Values.MasterTableView.CommandItemSettings.ShowExportToCsvButton = false; |
GridCommandItem commandItem = (GridCommandItem)rgForecastSummaryView_Values.MasterTableView.GetItems(GridItemType.CommandItem)[0]; |
LinkButton lnkbtn1 = (LinkButton)commandItem.FindControlRecursive("InitInsertButton"); |
lnkbtn1.Visible = false; |
} |
} |