Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Post
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
0
Reply
how to display images from folderto gridview in asp.net
narasiman rao
10 years ago
1.1k
Reply
My code as follows
protected void Page_Load(object sender, EventArgs e)
{
Lstfaculty.Items.Add("Raj");
Lstfaculty.Items.Add("suresh");
Lstfacid.Items.Add("1");
Lstfacid.Items.Add("2");
SetInitialRow();
}
private void SetInitialRow()
{
DataTable dt = new DataTable();
DataRow dr = null;
dt.Columns.Add("Faculty Name", typeof(string));
dt.Columns.Add("Faculty ID", typeof(string));
dt.Columns.Add("Photo",typeof(string));
for (int i = 0; i < Lstfaculty.Items.Count; i++)
{
dr = dt.NewRow();
dr["Faculty Name"] = Lstfaculty.Items[i].Text.ToString();
dt.Rows.InsertAt(dr, i);
}
for (int i = 0; i < dt.Rows.Count; i++)
{
dt.Rows[i]["Faculty ID"] = Lstfacid.Items[i].Text;
gvfaculty.DataSource = dt;
gvfaculty.DataBind();
}
}
When i execute my above code output as follows in Gridview
Faculty Name Faculty ID Photo
Raj 1
suresh 2
The above Raj and suresh images are stored in under E Folder Facultyimage.
in this Facultyimage folder(E Folder) the Raj and suresh images are there.
i want output as follows in Gridview
when i click the Raj(Faculty Name) in the gridview, i want to display the Raj image in the Photo column in gridiview.
Similarily when i click the suresh(Faculty Name) in the gridview, i want to display the suresh image in the Photo column in gridiview.
for that how can i do in asp.net using Csharp.
Regards,
Narasiman P.
Post
Reset
Cancel
Answers (
0
)
Next Recommended Forum
Input string was not in a correct format.
Sort c# List that contains json object