Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
1.0K+ views
Hi,

I am getting the error "Object reference not set to an instance of an object" when I click on Export to Excel button:

Here are the details:

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
   Telerik.Web.UI.GridTableView.PrepareExport() +72
   Telerik.Web.UI.Grid.Export.TableViewExporter.PrepareForExportInternal(GridTableView tableView, Boolean ignorePaging, Boolean dataOnly) +373
   Telerik.Web.UI.GridTableView.ClearTableViewControls(Control control, TableViewExporter exporter, GridTableView ownerTable) +597
   Telerik.Web.UI.Grid.Export.TableViewExporter.PrepareForExportInternal(GridTableView tableView, Boolean ignorePaging, Boolean dataOnly) +670
   Telerik.Web.UI.Grid.Export.TableViewExporter.PrepareForExport() +59
   Telerik.Web.UI.Grid.Export.TableViewExporter.page_PreRender(Object sender, EventArgs e) +34
   System.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.Control.OnPreRender(EventArgs e) +8686422
   System.Web.UI.Control.PreRenderRecursiveInternal() +80
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842


Version Information: Microsoft .NET Framework Version:2.0.50727.3623; ASP.NET Version:2.0.50727.3618



What might be the possible reason for this?

-Rajesh
Princy
Top achievements
Rank 2
 answered on 02 Aug 2011
2 answers
212 views
Please help me to set Text in InsertCaption and  and CaptionFormatString of EditFormSettings in Code Behind. Thanks
Henry John
Top achievements
Rank 1
 answered on 02 Aug 2011
2 answers
196 views

I am trying to use the Selected index of one RadComboBox help build the query to populate another RadComboBox, they are both in the <EditItemTemplate>.
I get an Object reference not set to instance of an object when I run this code just adding a RadComboBoxItem without even building the query.

Protected Sub ItemType_SelectedIndexChanged(ByVal o As Object, ByVal e As RadComboBoxSelectedIndexChangedEventArgs)
Dim DDL As RadComboBox = TryCast(RadGrid1.FindControl("FlatFileType").Controls(0), RadComboBox)
Dim RadComboBoxItem1 As New RadComboBoxItem("First Item")
DDL.Items.Add(RadComboBoxItem1)
End Sub

I am not sure how to correctly access the second radcombobox to be able to populate it.
Any help is greatly appreciated.

Bill
Top achievements
Rank 1
 answered on 02 Aug 2011
0 answers
108 views
rad ratin display bad
ali
Top achievements
Rank 1
 asked on 02 Aug 2011
2 answers
258 views
Hi all,
 
I am using the GridBoundColumn to display my DateTime data.
And I use the  DataFormatString="{0:MM/dd/yyyy}"  to make time invisible.
However, when export to Excel, it appears (see Image)
I just want to display day only.
<telerik:GridBoundColumn HeaderText="ETA Date" UniqueName="ETA_Date" DataField="ETA_Date" DataFormatString="{0:MM/dd/yyyy}" ReadOnly="true" SortExpression="ETA_Date"  >
     <HeaderStyle Font-Bold="True" Wrap="False" HorizontalAlign="Center"></HeaderStyle>
      <ItemStyle Wrap="False" HorizontalAlign="Center"></ItemStyle>
</telerik:GridBoundColumn>

Thanks.

Andy,
Andy
Top achievements
Rank 1
 answered on 01 Aug 2011
1 answer
74 views
If i comment out the selectvalue portion it works and i am able to ADD NEW Item.
If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
            Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)
 
            Dim Manufacturers As RadComboBox = CType(editedItem.FindControl("ManufacturerEdit"), RadComboBox)
            ProductsAccess.BindManufacturers(Manufacturers)
            'Dim Manufacturer As Integer = DataBinder.Eval(editedItem.DataItem, "Manufacturer").ToString
            'Manufacturers.SelectedValue = Manufacturer
 
            Dim Categories As RadComboBox = CType(editedItem.FindControl("CategoryEdit"), RadComboBox)
            ProductsAccess.BindCategories(Categories)
            'Dim Category As Integer = DataBinder.Eval(editedItem.DataItem, "Category").ToString
            'Categories.SelectedValue = Category

If i un-comment those lines i am only able to EDIT the items but when i click add new button it does nothing.
If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
            Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)
 
            Dim Manufacturers As RadComboBox = CType(editedItem.FindControl("ManufacturerEdit"), RadComboBox)
            ProductsAccess.BindManufacturers(Manufacturers)
            Dim Manufacturer As Integer = DataBinder.Eval(editedItem.DataItem, "Manufacturer").ToString
            Manufacturers.SelectedValue = Manufacturer
 
            Dim Categories As RadComboBox = CType(editedItem.FindControl("CategoryEdit"), RadComboBox)
            ProductsAccess.BindCategories(Categories)
            Dim Category As Integer = DataBinder.Eval(editedItem.DataItem, "Category").ToString
            Categories.SelectedValue = Category

ProductsAccess.BindManufacturers(Manufacturers) is a pretty simple Sub that bind combobox to datatable. I even tried with iterating DataRows in the DataTable.Rows collection and populating the combo one by one. The problem persisted :(
THanks
Jugoslav
Top achievements
Rank 1
 answered on 01 Aug 2011
1 answer
83 views
I have a grid inside a JQuery accordian control.  The grid is using the windows7 skin.
Alternate rows in the grid have white borders around vertcal edgaes of cells and bottom edges of cells.
Im assuming something is 'interfering' with the css of the grid.  How can I force the grid to not show these borders ?

Ive attached a screenshot to show whats happening
Pavlina
Telerik team
 answered on 01 Aug 2011
2 answers
228 views
Group,
Not sure there is an easy way to explain this, but basically I have an HTML table containing 4 columns with a bunch of RadTextBox controls.  What I am trying to do is iterate through each row of the HTML table and grab the the value of the RadTextBox based off of the cell index.

Below is a snippet of the code which appears to work for a regular asp textbox but not a radtextbox.  I get the error:
Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'Telerik.Web.UI.RadTextBox'.

foreach (HtmlTableRow row in uc.RecommendationTable.Rows)
{
 var rec1 = (RadTextBox)row.Cells[1].Controls[0];
}

 

i basically want to avoid having to use any find controls or anything because there are like 20 rows of 4 columns.  I want to iterate through each row and give me the value of the control located in each column of the HTML table.

Jon
Top achievements
Rank 1
 answered on 01 Aug 2011
1 answer
71 views
we update the data on the client and then process all changes on the server with a Grid /Client  Edit with single batch update .   
we are using this link  http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/clienteditbatchupdates/defaultcs.aspx
we have one problem,how to persist focus on grid pager when we update record on  one page ie pager index 1 and move to second page ie pager index  2,when we again go back to previous record ie on page 1 in grid it will go to page 1 but pager index is not updated it still focus on pager index 2. How to persist focus to pager index to previous page .



Jayesh Goyani
Top achievements
Rank 2
 answered on 01 Aug 2011
3 answers
202 views

In the following extracted code, column 'Id' is not visible at all times.  Column 'AE' should be invisible, too.  However, column 'AE' appears in the EditForm despite event ItemDataBound event which sets both columns Visible = False.

How can I hide column AE?


<
telerik:RadGrid ID="rgHeader" runat="server" CellSpacing="0" DataSourceID="sdsHeader">

<MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" DataSourceID="sdsHeader">

<CommandItemSettings ExportToPdfText="Export to PDF" AddNewRecordImageUrl="Images/new.png" AddNewRecordText="Add Header"></CommandItemSettings>

<Columns>

<telerik:GridButtonColumn Text="Select" CommandName="Select" UniqueName="Select" ItemStyle-Width="30px"></telerik:GridButtonColumn>

<telerik:GridEditCommandColumn></telerik:GridEditCommandColumn>

<telerik:GridBoundColumn DataField="AE" HeaderText="AE" SortExpression="AE" UniqueName="AE"></telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="Total" DataType="System.Int32" HeaderText="Total"

SortExpression="Total" UniqueName="Total">

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="Id" DataType="System.Int32" HeaderText="Id" ReadOnly="True"

SortExpression="Id" UniqueName="Id">

</telerik:GridBoundColumn>

</Columns>

<EditFormSettings>

<EditColumn UniqueName="EditCommandColumn1" FilterControlAltText="Filter EditCommandColumn1 column"></EditColumn>

</EditFormSettings>

</MasterTableView>

<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>

</telerik:RadGrid>


Protected Sub rgHeader_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles rgHeader.ItemDataBound

  rgHeader.MasterTableView.GetColumn(

"Id").Visible = False

  rgHeader.MasterTableView.GetColumn(

"AE").Visible = False

 

End Sub

 

Rick
Top achievements
Rank 1
 answered on 01 Aug 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?