hi!
how to display image in datagrid by using templatefield. i take one image control in itemtemplate field. please give a code
thanks.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Raaj KumarPosted Feb 20, 2010, 8:58 AM
Below is asp code,
and in code behind, I created a sample class for testing. You can modify it for your convinience,
public class Employee
{
public String Name { get; set; }
public String Age { get; set; }
public string ImageUrl { get; set; }
}
protected void Page_Load(object sender, EventArgs e)
{
IList < Employee > empList = new List
empList.Add(new Employee() { Name = "Name1", Age = "12", ImageUrl = "~/Images/Dog.gif" });
empList.Add(new Employee() { Name = "Name2", Age = "12", ImageUrl = "~/Images/Dog1.gif" });
empList.Add(new Employee() { Name = "Name3", Age = "12", ImageUrl = "~/Images/Dog2.jpg" });
empList.Add(new Employee() { Name = "Name4", Age = "12", ImageUrl = "~/Images/Dog3.jpg" });
if (!IsPostBack)
{
GridView1.DataSource = empList;
GridView1.DataBind();
}
}
Here I created a folder in the project and I placed all the images inside this.
Please let me know if you want more help
Regards,
Raaj