GridBoundColumn boundColumn = new GridBoundColumn();
view.Columns.Add(boundColumn);
boundColumn.DataField = "My.Custom.Object"; (note that Custom willbe null at some times, and therefore we cant sort the column).
The error occurs when I rebind the grid in Page_PreRender.
RadGrid1.DataSource = SomeDataSource;
try
{
RadGrid1.Rebind();
}
catch (Exception e)
{
// We will have a "Object reference not set to an instance of an object" error here...
}
Any way to get around this error?
Regards
Andreas Clausen
| <telerik:RadAjaxManager ID="ramManager" runat="server" DefaultLoadingPanelID="alpPan1" > |
| <AjaxSettings> |
| <telerik:AjaxSetting AjaxControlID="ramManager"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="lblCurDir" /> |
| <telerik:AjaxUpdatedControl ControlID="lblCurFile" /> |
| <telerik:AjaxUpdatedControl ControlID="imgPreview" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| </AjaxSettings> |
| </telerik:RadAjaxManager> |
| RadAjaxManager aM = RadAjaxManager.GetCurrent(Page); |
| if (aM == null) { |
| Response.Write("XFileExplorer needs an ajax manager in the page holding the control!"); |
| Response.End(); |
| return; |
| } |
| //calling ajax function changes grid and hidden fields - so add settings |
| aM.AjaxSettings.AddAjaxSetting(aM, hfCurDir); |
| aM.AjaxSettings.AddAjaxSetting(aM, hfCurFile); |
| aM.AjaxSettings.AddAjaxSetting(aM, rgBackupFiles); |
| aM.UpdatePanelsRenderMode = UpdatePanelRenderMode.Inline; |
| <telerik:RadAjaxManager ID="ramManager" runat="server" DefaultLoadingPanelID="alpPan1" > |
| <AjaxSettings> |
| <telerik:AjaxSetting AjaxControlID="ramManager"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="lblCurDir" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| <telerik:AjaxSetting AjaxControlID="ramManager"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="lblCurFile" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| <telerik:AjaxSetting AjaxControlID="ramManager"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="imgPreview" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| </AjaxSettings> |
| </telerik:RadAjaxManager> |
| AjaxSetting aS = new AjaxSetting(aM.ID); |
| string strLoadPanelID=aM.DefaultLoadingPanelID; //use default loading panel |
| aS.UpdatedControls.Add(new AjaxUpdatedControl(rgBackupFiles.ID, strLoadPanelID)); |
| aS.UpdatedControls.Add(new AjaxUpdatedControl(hfSaveCurDir.ID,strLoadPanelID)); |
| aS.UpdatedControls.Add(new AjaxUpdatedControl(hfSaveCurFile.ID,strLoadPanelID)); |
| aM.AjaxSettings.Add(aS); |
| aM.UpdatePanelsRenderMode = UpdatePanelRenderMode.Inline; |
| //calling ajax function changes grid and hidden fields - so add settings |
| AjaxSetting aS = new AjaxSetting(aM.ID); |
| string strLoadPanelID=aM.DefaultLoadingPanelID; //use default loading panel |
| //CANT DO THIS - WOULD REMOVE RENDER MODE aS.UpdatedControls.Add(new AjaxUpdatedControl(rgBackupFiles.ID, strLoadPanelID)); |
| aS.UpdatedControls.Add(new AjaxUpdatedControl(hfSaveCurDir.ID,strLoadPanelID)); |
| aS.UpdatedControls.Add(new AjaxUpdatedControl(hfSaveCurFile.ID,strLoadPanelID)); //add extra to preserver inline mode |
| aM.AjaxSettings.Add(aS); |
| aM.UpdatePanelsRenderMode = UpdatePanelRenderMode.Inline; |
| aM.AjaxSettings.AddAjaxSetting(aM, rgBackupFiles); |
In our application we have a Radgrid that contains several GridBoundColumns and a few GridCheckBoxColumns. Here is the code that defines 2 of them:
<telerik:GridBoundColumn
UniqueName="gbcWBSNumber"
DataField="WBSNumber"
HeaderStyle-HorizontalAlign="Center"
ItemStyle-HorizontalAlign="Center"
HeaderText="WBS #">
</telerik:GridBoundColumn>
<telerik:GridCheckBoxColumn
UniqueName="gccAllowBoes"
DataField="AllowBoes"
HeaderStyle-HorizontalAlign="Center"
ItemStyle-HorizontalAlign="Center"
HeaderText="Allow<br />BOEs">
</telerik:GridCheckBoxColumn>
We need a way to adjust the settings of these two objects using JavaScript. We are doing this successfully for the GridBoundColumn but not for the GridCheckBoxColumn.
In the following (greatly abbreviated) JavaScript we are able to obtain a reference to both objects(stored in the global variables WBSNumber and AllowBOEs respectively):
function WBSGridDoubleClick(sender, eventArgs)
{
(code removed…)
WBSNumber = MasterTableView.getCellByColumnUniqueName(MasterTableView.get_dataItems()[index], "gbcWBSNumber");
AllowBOES = MasterTableView.getCellByColumnUniqueName(MasterTableView.get_dataItems()[index], "gccAllowBOEs");
(code removed…)
}
After some other processing we acquire new values that we need to use to reset these two objects.
We have the following JavaScript code in our program to hopefully accomplish this:
function OnClientCloseWBSEast(oWnd)
{
// call a webservice to retrieve the modified data
WBSData.GetThisWBS(keyValues, OnGetThisWBSComplete);
}
// dt is actually an array of strings that contains the
// information we need
function OnGetThisWBSComplete(dt)
{
WBSNumber.innerText = dt[0]; // works fine!!!
AllowBOES.innertext = dt[4] // returns ‘true’ or ‘false’
}
Unfortunately, even though the value returned from the webservice in dt[4] reflects the latest change by the user, the ‘innerText’ property causes the checkbox to be removed and the value ‘true’ or ‘false’ to appear in the cell.
We have also tried innerHTML, value, and checked as properties for our CheckBox object but none of these work any better.
Can someone tell us what the proper syntax would be?
Thanks.
I'd like to change (or possibly remove) the toggle icon (+/- next to the text) on one (but not all) of my TreeViews. Is this possible?
Thanks,
Tommy