You can store some thumbnails in a table in data base. Such as naming the thumbnail of .doc file as 1.jpg, naming the thumbnail of .wma file as 2.jpg. See the following codes and you can write some in your .cs file. ("e.Row.Cells[2].Text" stands for the
route of your file. Variable "mark" is used for not showing pictures in the 1st row)
if (mark != 0)
{
if (e.Row.Cells[2].Text.ToString().Contains(".doc"))
{
Image img = new Image();
img.ImageUrl = "Img\\" + 1 + ".jpg";
TableCell tc = new TableCell();
tc.Controls.Add(img);
e.Row.Cells.Add(tc);
}
else if (e.Row.Cells[2].Text.ToString().Contains(".wma"))
{
Image img = new Image();
img.ImageUrl = "Img\\" + 2 + ".jpg";
TableCell tc = new TableCell();
tc.Controls.Add(img);
e.Row.Cells.Add(tc);
}
else if (e.Row.Cells[2].Text.ToString().Contains(".jpg"))
{
Image img = new Image();
img.ImageUrl = e.Row.Cells[2].Text.ToString();
TableCell tc = new TableCell();
tc.Controls.Add(img);
e.Row.Cells.Add(tc);
}
}
mark++;
Hope this will do help for you. Reply me if you have any doubts.
Marked as answer by programercek on Aug 15, 2012 08:15 PM
Superguppie.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
Marked as answer by programercek on Aug 15, 2012 08:15 PM
programercek
Participant
1508 Points
2218 Posts
how to open different file in gridview,or...
Aug 11, 2012 04:58 PM|LINK
Hello,
I uploaded files as .doc, .jpg,etc...
How to show with gridview,or... like this:
Kenon-YGN
Member
378 Points
51 Posts
Re: how to open different file in gridview,or...
Aug 13, 2012 08:25 AM|LINK
Hi,
You can store some thumbnails in a table in data base. Such as naming the thumbnail of .doc file as 1.jpg, naming the thumbnail of .wma file as 2.jpg. See the following codes and you can write some in your .cs file. ("e.Row.Cells[2].Text" stands for the route of your file. Variable "mark" is used for not showing pictures in the 1st row)
if (mark != 0)
{
if (e.Row.Cells[2].Text.ToString().Contains(".doc"))
{
Image img = new Image();
img.ImageUrl = "Img\\" + 1 + ".jpg";
TableCell tc = new TableCell();
tc.Controls.Add(img);
e.Row.Cells.Add(tc);
}
else if (e.Row.Cells[2].Text.ToString().Contains(".wma"))
{
Image img = new Image();
img.ImageUrl = "Img\\" + 2 + ".jpg";
TableCell tc = new TableCell();
tc.Controls.Add(img);
e.Row.Cells.Add(tc);
}
else if (e.Row.Cells[2].Text.ToString().Contains(".jpg"))
{
Image img = new Image();
img.ImageUrl = e.Row.Cells[2].Text.ToString();
TableCell tc = new TableCell();
tc.Controls.Add(img);
e.Row.Cells.Add(tc);
}
}
mark++;
Hope this will do help for you. Reply me if you have any doubts.
superguppie
All-Star
48225 Points
8679 Posts
Re: how to open different file in gridview,or...
Aug 14, 2012 09:39 AM|LINK
You will have to check the type and set the imageurl accordingly.
If you want it in .aspx, you could put in an image for each type, and bind Visible to a type-check. Something like (C#)
<asp:Image runat="server" ID="DocImage" ImageUrl="~/Images/doc.jpg" Visible='<%# (String)Eval("file-type") == "doc" %>' />Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.