displaying image in datalist.?
-
i want to display my images in datalist. i save my images path in access database(like this Product\hotel\product1.gif) my images are in a speial folder which under the App_Data. how can i connect datalist-images directory-image? i connected to database with accessdatasource1.
-
i want to display my images in datalist. i save my images path in access database(like this Product\hotel\product1.gif) my images are in a speial folder which under the App_Data. how can i connect datalist-images directory-image? i connected to database with accessdatasource1.
U need to use an Image Control in DataList(Edit Template) and set the Image Control URL in ItemDataBound event of DataList
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
Image I1 = (Image)(e.Item.FindControl("Imagex"));
I1.ImageUrl = dth.Rows[e.Item.ItemIndex]["ImageURL"].ToString();
}"dth" is the DataTable which I am using as DataSource for DataList The URL should be "App_Data/product1.gif",to retrieve the image . As in ur case if URL is stored as eg:Product\hotel\product1.gif Then you need to convert it to "App_Data/product1.gif", using string manipulation .