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

GridImageColumn

1 Answer 105 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Erin
Top achievements
Rank 1
Erin asked on 26 Nov 2013, 01:09 PM
Hi,
I have a GridImageColumn , on its button click I want to select that row. How to achieve this? 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 26 Nov 2013, 01:22 PM
Hi Erin,

Please attach an OnClick event to the Image from ItemCreated event of the Radgrid as follows:

ASPX:
<telerik:GridImageColumn DataType="System.String" DataImageUrlFields="CustomerID"
    DataImageUrlFormatString="IMG/{0}.jpg" AlternateText="Customer image" DataAlternateTextField="ContactName"
    ImageAlign="Middle" ImageHeight="50px" ImageWidth="50px" HeaderText="Image Column"
    FooterText="ImageColumn footer" UniqueName="GridImageColumn">
</telerik:GridImageColumn>

C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
 {
   if (e.Item is GridDataItem)
   {
       GridDataItem data = (GridDataItem)e.Item;
       System.Web.UI.WebControls.Image imgecol = (System.Web.UI.WebControls.Image)data["GridImageColumn"].Controls[0];
       imgecol.Attributes.Add("OnClick", "Click('" + data.ItemIndex + "')");
   }
 }

JS:
<script type="text/javascript">
    function Click(index) {
        var masterTable = $find("<%=RadGrid1.ClientID%>").get_masterTableView();
        masterTable.fireCommand("Select", index);
    }
</script>

Thanks,
Princy
Tags
Grid
Asked by
Erin
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or