Add Image to Details GridTableView via RadGrid1_ItemDataBound

1 Answer 86 Views
Grid
Jason
Top achievements
Rank 1
Iron
Jason asked on 27 Aug 2022, 02:32 PM | edited on 28 Aug 2022, 07:15 AM

My RadGrid has multiple GridTableViews, I have tested my ItemDataBound code on a RadGrid with no GridTableViews and the image gets added as expected. 

The problem is the code in the ItemDataBound needs adjusting to be able to access the GridTableView with the name "ReviewLabel"

as the error is "Cannot find a cell bound to column name 'photoid'

Please can someone show me how to rewrite this please

This is the ItemDataBound Code


  protected void RadGrid1_ItemDataBound1(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
            string s = item["photoid"].Text;
            if (s == null || s == string.Empty || s == "" || s.Length < 2 || s == "&nbsp;")
            {
                //code
            }
            else
            {
               //code
            }
        }
    }

Thanks

Jason

1 Answer, 1 is accepted

Sort by
0
Accepted
Jason
Top achievements
Rank 1
Iron
answered on 28 Aug 2022, 07:13 AM

So I discovered the way to access the dataitem in the tableview is like this

if ((e.Item is GridDataItem) && (e.Item.OwnerTableView.Name == "ReviewLabel"))

{

//code

}

Tags
Grid
Asked by
Jason
Top achievements
Rank 1
Iron
Answers by
Jason
Top achievements
Rank 1
Iron
Share this question
or