Will do in 2 steps
1)You need to save image url in database and same image you need to save in your project folder using property
FileUpload1.SaveAs(strSavePath)
where fileUpload1 is the fileupload control and strSavePath is the variable where you assigned the path where you want to save the image.
2)Now following snippet is the part of grid view control ,that is template field by using template field you add asp:image cotrol and give the column name as value to the property imageUrl of asp.net image control as
ImageUrl ="'<%# Eval("Url") %>'"
<asp:TemplateField>
<HeaderTemplate>
<asp:Label ID="lblimg" runat="server">Image</asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:Image ImageUrl ="'<%# Eval("Url") %>'" runat="server" ID="imgCar" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField></pre>
now just bind the datatable to gridview ,your work is done.
Quote:
After looking the comment for JsonMacD. i can say that you need to play at database level also with this above coding as following way.
create user defined function like this
create function fnreturn(@RoleId int) returns varchar(50)
as
Begin
Declare @Result varchar(50)
if((select count(*) from DashBoardItems where roleId=@RoleId)>2)
Begin
set @Result= '~/Image/upArrow.png'
End
Else
Begin
set @Result= '~/Image/DownArrow.png'
END
return @Result
ENd
which will return based on condition
and then use this function in your select query like this
select *,dbo.fnreturn(8) as URl from DashBoardItems
then now just you need to bind the result table to gridview.
Hope This will help-Happy coding