Click here to Skip to main content
15,915,019 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i want to call images id wise from folder by using Asp:Data List i am doing like that.

C#
 if (Request.QueryString.Count > 0)
            {
                string[] filePaths = Directory.GetFiles(Server.MapPath("~/DistributorShopImages/" ));
                List<listitem> files = new List<listitem>();
                foreach (string filePath in filePaths)
                {
                    string fileName = Path.GetFileName(filePath);
                    files.Add(new ListItem(fileName, "~/DistributorShopImages/" + fileName));
                }
                DataList1.DataSource = files;
                DataList1.DataBind();
}
Posted
Updated 5-Nov-15 1:45am
v4
Comments
ZurdoDev 5-Nov-15 7:41am    
Do you have a question?
Noman Suleman 5-Nov-15 7:43am    
i want to call images id wise from folder by using Asp:Data List
ZurdoDev 5-Nov-15 7:51am    
OK. Why can't you? And what do you mean?
Noman Suleman 5-Nov-15 7:57am    
i am confuse, that where to pass id to get files from folder

{
string[] filePaths = Directory.GetFiles(Server.MapPath("~/DistributorShopImages/" ));
List<listitem> files = new List<listitem>();
foreach (string filePath in filePaths)
{
string fileName = Path.GetFileName(filePath);
files.Add(new ListItem(fileName, "~/DistributorShopImages/" + fileName));
}
DataList1.DataSource = files;
DataList1.DataBind();
}
Debojyoti Saha 5-Nov-15 7:58am    
what do you mean by Image ID

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900