Hi,
I am using the RadGrid and am inserting an image into a GridBoundColumn using the ItemDataBound event, this all works fine. However when I click on a column to sort all the text columns are sorted correctly but the images do not move.
Am I missing something?
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="true" AutoGenerateColumns="False" CssClass="RadGrid" GridLines="None" GroupingEnabled="False" HorizontalAlign="NotSet" OnItemDataBound="RadGrid1_ItemDataBound" OnNeedDataSource="RadGrid1_NeedDataSource" PageSize="20" ShowStatusBar="True" Skin="Office2007"> | |
<HeaderStyle CssClass="RadGridHeader" /> | |
<PagerStyle Mode="NextPrevAndNumeric" /> | |
<MasterTableView CommandItemDisplay="None" GridLines="None" AllowMultiColumnSorting="True"> | |
<Columns> | |
<telerik:GridBoundColumn DataField="ImagePath" HeaderText="" ReadOnly="True" SortExpression="ImagePath"> | |
</telerik:GridBoundColumn> | |
<telerik:GridHyperLinkColumn DataNavigateUrlFields="InterviewerID" DataNavigateUrlFormatString="InterviewerAdministration.aspx?id={0}" DataTextField="FullName" HeaderText="Name" SortExpression="FullName" UniqueName="FullName"> | |
</telerik:GridHyperLinkColumn> | |
<telerik:GridBoundColumn DataField="InterviewerRegionName" HeaderText="Region" ReadOnly="True" SortExpression="InterviewerRegionName" UniqueName="InterviewerRegionName"> | |
</telerik:GridBoundColumn> | |
<telerik:GridBoundColumn DataField="PostCode" HeaderText="Post Code" ReadOnly="True" SortExpression="PostCode" UniqueName="PostCode"> | |
</telerik:GridBoundColumn> | |
<telerik:GridBoundColumn DataField="RoleType" HeaderText="Primary Role" ReadOnly="True" SortExpression="RoleType" UniqueName="RoleType"> | |
</telerik:GridBoundColumn> | |
<telerik:GridBoundColumn DataField="HomeTelephoneNumber" HeaderText="Telephone Number" ReadOnly="True" SortExpression="HomeTelephoneNumber" UniqueName="HomeTelephoneNumber"> | |
</telerik:GridBoundColumn> | |
<telerik:GridBoundColumn DataField="EmailAddress" HeaderText="Email" ReadOnly="True" SortExpression="EmailAddress" UniqueName="EmailAddress"> | |
</telerik:GridBoundColumn> | |
<telerik:GridBoundColumn DataField="AlertType" HeaderText="Alert Type" ReadOnly="True" SortExpression="AlertType" UniqueName="AlertType"> | |
</telerik:GridBoundColumn> | |
</Columns> | |
</MasterTableView> | |
</telerik:RadGrid> |
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) | |
{ | |
if (e.Item is GridDataItem) | |
{ | |
string sPath = ConfigurationManager.AppSettings["ImagePath"]; | |
string sImageName = "NoImageSelected.GIF"; | |
string sToolTip = "No image available"; | |
DataRowView view = (DataRowView)e.Item.DataItem; | |
if (view.DataView[e.Item.ItemIndex]["ImagePath"] != DBNull.Value) | |
{ | |
sImageName = (string)view.DataView[e.Item.ItemIndex]["ImagePath"]; | |
sToolTip = (string)view.DataView[e.Item.ItemIndex]["FullName"]; | |
} | |
Image img = new Image(); | |
img.ImageUrl = string.Concat(sPath, sImageName); | |
img.ToolTip = sToolTip; | |
img.Height = new Unit("100px"); | |
((GridDataItem)e.Item)["ImagePath"].Controls.Add(img); | |
} | |
} |