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

Image inside radgrid doesn't refresh after rebind

1 Answer 84 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Covertix
Top achievements
Rank 1
Covertix asked on 21 Aug 2012, 11:03 AM
Hi,

I have a rad grid with a template column that contains image:

<telerik:GridTemplateColumn

HeaderText="Status" HeaderStyle-Width="50px" ItemStyle-Width="16px"

UniqueName="SensorConnectionStatus" AllowFiltering="false">

<ItemTemplate>

<asp:Image ID="StatusImage" runat="server" Width="16px" Height="16px"/>

</ItemTemplate>

</telerik:GridTemplateColumn>


In the databound column I have the following code:

 

        if (e.Item is GridDataItem)
        {
            GridDataItem myGridItem = (GridDataItem)e.Item;
            bool IsOnlineSensor = IsOnline(DataBinder.Eval(e.Item.DataItem, "SensorConnectionStatusCode"));

            Image image = (Image)myGridItem["SensorConnectionStatus"].FindControl("StatusImage");

            if (IsOnlineSensor)
            {
                image.ImageUrl = "~/Images/Design/a.png";
                image.ToolTip = "Online";
            }
            else
            {
                image.ImageUrl = "~/Images/Design/b.png";
                image.ToolTip = "Offline";
            }
        }


I have a refresh button that calls the client side function that should rebind the grid:

function RebindCxSensorsGrid() {

 

var masterTable = $find("<%= gvSensors.ClientID %>").get_masterTableView();

masterTable.rebind();

}

The problem is that I have an online sensor with the image a.png, but after I press the refresh button it should change to offline and display b.png in the grid.
I put a breakpoint and I see that the data is correct, but the image didn't change...

Do you have any idea what am I doing wrong?
If I load the page again, the icon changes.

Thanks.

 

 

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 23 Aug 2012, 11:33 AM
Hello Tzach,

I have created a sample RadGrid web site where I implemented the requested functionality. On my side everything works as expected and the images are being modified correctly. Please check out the attached application and let me know if it helps you.

Regards,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Covertix
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or