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

image from folder

4 Answers 77 Views
ListView
This is a migrated thread and some comments may be shown as answers.
rastin
Top achievements
Rank 1
rastin asked on 01 Jun 2011, 05:16 PM
hi all
i want read all of my fields of table and in each record have an image button that show image that its name is "~\Image\"+fieldname(one of table field).
how can do this?
thankful.

4 Answers, 1 is accepted

Sort by
0
Gimmik
Top achievements
Rank 1
answered on 01 Jun 2011, 09:08 PM
Hi Rastin,

Which RadControls are you using? Do you just need to know how to set a button image dynamically.

-Gimmik
0
rastin
Top achievements
Rank 1
answered on 02 Jun 2011, 06:18 AM
Hi Gimmik
i used RadListView
thankful.
0
Accepted
Gimmik
Top achievements
Rank 1
answered on 03 Jun 2011, 04:07 PM
Hi Rastin,

I've been looking into the issue. This should be possible to do. I think the key is going to be wiring-up the PreRender event for the RadImageButton to set the ImageURL. You'll have to access the cell in whichever RadControl you are using that contains the file name for the image. I made an example using a RadGrid. The file name is in column 0, and that file name is used to create the URL for the RadImageButton which is in column 1 of the same row.

I hope this is clear - let me know if you have questions.
-Gimmik

protected void RadButton1_OnPreRender(object sender, EventArgs e)
{
    RadButton btn = (sender as RadButton);
 
    GridDataItem dataItem = btn.Parent.Parent as GridDataItem;
 
    String filename = dataItem["filename"].Text;
    String fullPath = "~/Image/" + filename;
    btn.Image.ImageUrl = fullPath;
}
0
rastin
Top achievements
Rank 1
answered on 03 Jun 2011, 04:49 PM
very thankful Gimmik for your help.
thankful.
Tags
ListView
Asked by
rastin
Top achievements
Rank 1
Answers by
Gimmik
Top achievements
Rank 1
rastin
Top achievements
Rank 1
Share this question
or