user3672020
user3672020

Reputation: 27

Add picture into GridViewImageColumn

I try to add picture to my GridViewImageColumn and found this tutorial

this is my code (from the link above):

GridViewImageColumn imageColumn = new GridViewImageColumn();
imageColumn.Name = "ImageColumn";
imageColumn.FieldName = "Photo";
imageColumn.HeaderText = "Picture";
imageColumn.ImageLayout = ImageLayout.Zoom;           
radGridView1.MasterTemplate.Columns.Insert(4, imageColumn);

So my question is where the pace that i need to specify my image path ?

Upvotes: 1

Views: 2940

Answers (3)

EugenSunic
EugenSunic

Reputation: 13733

Try to implement something like this in your .aspx file and see how it goes...

<telerikGridView:RadGridView.Columns>

 <telerikGridView:GridViewColumn UniqueName="img" Width="">

<telerikGridView:GridViewColumn.CellTemplate>
  <DataTemplate>
    <Image Stretch="None" Source="../Images/MyImage.png" /> // just an example path
  </DataTemplate>
  </telerikGridView:GridViewColumn.CellTemplate>

 </telerikGridView:GridViewColumn>

</telerikGridView:RadGridView.Columns>

Upvotes: 0

Erdogan
Erdogan

Reputation: 1000

You can try DataMemberBinding="{Binding [Image]}" instead.

Upvotes: 0

varsha
varsha

Reputation: 1620

try this

Collapse imageGridImageColumn

Each cell in a GridImageColumn contains an image. To specify the image URL of that image, you can do one of the following:

Set the ImageUrl property to a static value. When you use this method, every image appears the same in the entire column.

Set the DataImageUrlFields property to a field in the source that can be used to supply the image path and format it by setting the DataImageUrlFormatString property. You can specify multiple fields if the image URL is determined by more than one field in the database.

Set the DataAlternateTextField property to specify by which field in the grid source the column will be sorted/filtered. For the filtering, you must also explicitly set the DataType property of the column to the type of the field specified through the DataAlternateTextField property (System.String in the common case). You can also apply formatting using the DataAlternateTextFormatString property. 

[Note] Note

Note that if you specify a sort expression directly through the SortExpression property of the column, it will have a higher priority and will override the sort/filter criteria of the DataAlternateTextField property.

Other commonly used properties for that column are AlternateText, ImageAlign, ImageWidth, ImageHeight, etc. The following example shows the declaration of a GridImageColumn from this online demo of the product: CopyASPX

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

Upvotes: 1

Related Questions