can we retrive image from database in gridview

Posted by Deepakji under C# on 3/27/2012 | Points: 10 | Views : 2249 | Status : [Member] | Replies : 2
hi,

i am working with grid view i am able to get data but the problem is that in my database i have both data means text and image so image is saved in form of bytes now i want to get both in gridview but i am able to text but not the image so please let me know whether we can do that or not because both will display in same row its like (answer with image ) . if we can do how to do that its urgent as i am not that much familiar with this concepts.




Responses

Posted by: Sksamantaray on: 3/27/2012 [Member] Silver | Points: 25

Up
0
Down
Hi
refer to this:
http://www.aspsnippets.com/Articles/Display-images-from-SQL-Server-Database-in-ASP.Net-GridView-control.aspx

Thanks,
Sanjay

Deepakji, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Deepakji on: 3/27/2012 [Member] Starter | Points: 25

Up
0
Down
hi, i am unable to get it images are not getting displayed and in articel i am not getting what is this imagehandler so please let me know

i am giving u the data also

in aspx
<asp:GridView ID="gd" runat="server" AutoGenerateColumns="false">
<Columns>


<asp:TemplateField >
<HeaderTemplate>Qno</HeaderTemplate>
<ItemTemplate><asp:Label ID="lblQno" runat="server" Text='<%#Container.DataItemIndex+1%>'></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>Image</HeaderTemplate>
<ItemTemplate>
<asp:Image ID="im" runat="server" ImageUrl='' />

</ItemTemplate>


</asp:TemplateField>
</Columns>



</asp:GridView>

in .cs file

protected void Page_Load(object sender, EventArgs e)
{

SqlConnection con = new SqlConnection("User Id=**;Password=**;Initial Catalog=QuestionPaper;Data Source=**");
SqlDataAdapter dr = new SqlDataAdapter("select questionimage from imageinfo ", con);
DataSet ds = new DataSet();
dr.Fill(ds);
gd.DataSource = dr;
gd.DataBind();
}


Deepakji, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response