This is a migrated thread and some comments may be shown as answers.

[Solved] Object reference not set

4 Answers 197 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Warren
Top achievements
Rank 1
Warren asked on 23 May 2008, 12:42 PM
I've added tooltips to my grid using this code

  Protected Sub RadGrid1_ItemCreated(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated 
    If (TypeOf e.Item Is GridDataItem) Then 
      Dim gridItem As GridDataItem = CType(e.Item, GridDataItem) 
      Dim ent As OrderTrackingViewEntity = CType(e.Item.DataItem, OrderTrackingViewEntity) 
 
      If Not String.IsNullOrEmpty(ent.WarehouseComments) Then 
        For Each column As GridColumn In RadGrid1.MasterTableView.RenderColumns 
          '    If (TypeOf column Is GridBoundColumn) Then 
          '      gridItem(column.UniqueName).ToolTip = ent.WarehouseComments '(gridItem.OwnerTableView.DataKeyValues(gridItem.ItemIndex)("WarehouseComments").ToString) 
          '    End If 
        Next 
      End If 
    End If 
  End Sub 


If I uncomment the 3 lines in the for each loop I get this error

Object reference not set to an instance of an object

when I click on any rows edit button, it works fine if I live the lines commented out.

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 26 May 2008, 04:30 AM
Hi Warren , 

Go through the following help article.
Adding tooltips for grid items

Shinu.
0
Warren
Top achievements
Rank 1
answered on 26 May 2008, 12:53 PM
That's the article I based my code on; I'm not sure what I'm missing that will fix my problem?
0
Shinu
Top achievements
Rank 2
answered on 27 May 2008, 05:55 AM
Hi Warren,

Can you try adding the ToolTip in the ItemDataBound event ?

CS:
 protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            string strTxt = item["columnUniqueName"].Text.ToString(); 
            if (strTxt == "Edit") 
            { 
                item["columnUniqueName"].ToolTip = "Click Here to Edit"
            } 
        } 
   } 


Thanks
Shinu.
0
Accepted
Warren
Top achievements
Rank 1
answered on 27 May 2008, 07:57 PM
That fixed it.

Thanks!
Tags
Grid
Asked by
Warren
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Warren
Top achievements
Rank 1
Warren
Top achievements
Rank 1
Share this question
or