Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > how to show an Image field from a SQL Server table field to a aspx page

Reply
Thread Tools

how to show an Image field from a SQL Server table field to a aspx page

 
 
J Sahoo
Guest
Posts: n/a
 
      07-06-2004
Hi,
I have a browse page where I am showing few fields from my SQL Server
table. One of the field is Image type, all the fields are bound to a
single table.

I want to show the image from the table on this browse along with the
other fields. Here is the code what I have from the HTML view, I am
using a datagrid to show the result. It does not show the image rather
it shows "System.Byte[] " on the output. I did not have any code
behind page logic for this image field (mypicture).

Thank you.

Sahoo J

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>


<asp:datagrid id=DataGrid1 runat="server" ForeColor="Black"
Width="520px" BorderColor="Tan" Height="358px" DataSource="<%# DsPict1
%>" DataMember="SahooPhoneTbl" AutoGenerateColumns="False"
BorderWidth="1px" BackColor="LightGoldenrodYellow" CellPadding="2"
GridLines="None">
<SelectedItemStyle ForeColor="GhostWhite"
BackColor="DarkSlateBlue"></SelectedItemStyle>
<AlternatingItemStyle
BackColor="PaleGoldenrod"></AlternatingItemStyle>
<HeaderStyle Font-Bold="True" BackColor="Tan"></HeaderStyle>
<FooterStyle BackColor="Tan"></FooterStyle>
<Columns>
<asp:HyperLinkColumn Text="Edit"
DataNavigateUrlField="Employee_Id"
DataNavigateUrlFormatString="MaintCourseCode.aspx? parmCourseCode={0}&amp;usrAction=Edt">
<HeaderStyle Font-Bold="True"></HeaderStyle>
</asp:HyperLinkColumn>
<asp:HyperLinkColumn Text="Delete"
DataNavigateUrlField="Employee_Id"
DataNavigateUrlFormatString="MaintCourseCode.aspx? parmCourseCode={0}&amp;usrAction=Del">
<HeaderStyle Font-Bold="True"></HeaderStyle>
</asp:HyperLinkColumn>
<asp:TemplateColumn HeaderText="Status">
<HeaderStyle Font-Bold="True"></HeaderStyle>
<ItemStyle HorizontalAlign="Left"></ItemStyle>
<ItemTemplate>
<div align="center">
<IMG SRC='<%# Container.DataItem("mypicture") %>'
Border="0">
<br>
<%# (Container.DataItem("mypicture")) %>
</div>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="Phone" SortExpression="Phone"
HeaderText="Phone"></asp:BoundColumn>
<asp:BoundColumn DataField="Name" SortExpression="Name"
HeaderText="Name"></asp:BoundColumn>
<asp:BoundColumn DataField="Employee_Id"
SortExpression="Employee_Id"
HeaderText="Employee_Id"></asp:BoundColumn>
</Columns>
<PagerStyle HorizontalAlign="Center"
ForeColor="DarkSlateBlue" BackColor="PaleGoldenrod"></PagerStyle>
</asp:datagrid></div>
 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      07-06-2004
IE does not support inline images. your table should have a url to the
image, then you write an aspx page that display the image. a quick google of
this newgroup will show lots of examples.

-- bruce (sqlwork.com)


"J Sahoo" <> wrote in message
news: m...
> Hi,
> I have a browse page where I am showing few fields from my SQL Server
> table. One of the field is Image type, all the fields are bound to a
> single table.
>
> I want to show the image from the table on this browse along with the
> other fields. Here is the code what I have from the HTML view, I am
> using a datagrid to show the result. It does not show the image rather
> it shows "System.Byte[] " on the output. I did not have any code
> behind page logic for this image field (mypicture).
>
> Thank you.
>
> Sahoo J
>
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>

>
> <asp:datagrid id=DataGrid1 runat="server" ForeColor="Black"
> Width="520px" BorderColor="Tan" Height="358px" DataSource="<%# DsPict1
> %>" DataMember="SahooPhoneTbl" AutoGenerateColumns="False"
> BorderWidth="1px" BackColor="LightGoldenrodYellow" CellPadding="2"
> GridLines="None">
> <SelectedItemStyle ForeColor="GhostWhite"
> BackColor="DarkSlateBlue"></SelectedItemStyle>
> <AlternatingItemStyle
> BackColor="PaleGoldenrod"></AlternatingItemStyle>
> <HeaderStyle Font-Bold="True" BackColor="Tan"></HeaderStyle>
> <FooterStyle BackColor="Tan"></FooterStyle>
> <Columns>
> <asp:HyperLinkColumn Text="Edit"
> DataNavigateUrlField="Employee_Id"
>

DataNavigateUrlFormatString="MaintCourseCode.aspx? parmCourseCode={0}&amp;usr
Action=Edt">
> <HeaderStyle Font-Bold="True"></HeaderStyle>
> </asp:HyperLinkColumn>
> <asp:HyperLinkColumn Text="Delete"
> DataNavigateUrlField="Employee_Id"
>

DataNavigateUrlFormatString="MaintCourseCode.aspx? parmCourseCode={0}&amp;usr
Action=Del">
> <HeaderStyle Font-Bold="True"></HeaderStyle>
> </asp:HyperLinkColumn>
> <asp:TemplateColumn HeaderText="Status">
> <HeaderStyle Font-Bold="True"></HeaderStyle>
> <ItemStyle HorizontalAlign="Left"></ItemStyle>
> <ItemTemplate>
> <div align="center">
> <IMG SRC='<%# Container.DataItem("mypicture") %>'
> Border="0">
> <br>
> <%# (Container.DataItem("mypicture")) %>
> </div>
> </ItemTemplate>
> </asp:TemplateColumn>
> <asp:BoundColumn DataField="Phone" SortExpression="Phone"
> HeaderText="Phone"></asp:BoundColumn>
> <asp:BoundColumn DataField="Name" SortExpression="Name"
> HeaderText="Name"></asp:BoundColumn>
> <asp:BoundColumn DataField="Employee_Id"
> SortExpression="Employee_Id"
> HeaderText="Employee_Id"></asp:BoundColumn>
> </Columns>
> <PagerStyle HorizontalAlign="Center"
> ForeColor="DarkSlateBlue" BackColor="PaleGoldenrod"></PagerStyle>
> </asp:datagrid></div>



 
Reply With Quote
 
 
 
 
J Sahoo
Guest
Posts: n/a
 
      07-07-2004
I am intrested in knowing how to get an image from a database field, I
was able to do it thru a link from the HTML. But how do I convert this
image (from a database field) to show it on a datagrid (so that HTML
can show it). Any sample code will be appreciated. Thanks.

Sahoo J

"bruce barker" <> wrote in message news:<>...
> IE does not support inline images. your table should have a url to the
> image, then you write an aspx page that display the image. a quick google of
> this newgroup will show lots of examples.
>
> -- bruce (sqlwork.com)
>
>
> "J Sahoo" <> wrote in message
> news: m...
> > Hi,
> > I have a browse page where I am showing few fields from my SQL Server
> > table. One of the field is Image type, all the fields are bound to a
> > single table.
> >
> > I want to show the image from the table on this browse along with the
> > other fields. Here is the code what I have from the HTML view, I am
> > using a datagrid to show the result. It does not show the image rather
> > it shows "System.Byte[] " on the output. I did not have any code
> > behind page logic for this image field (mypicture).
> >
> > Thank you.
> >
> > Sahoo J
> >
> > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>

> >
> > <asp:datagrid id=DataGrid1 runat="server" ForeColor="Black"
> > Width="520px" BorderColor="Tan" Height="358px" DataSource="<%# DsPict1
> > %>" DataMember="SahooPhoneTbl" AutoGenerateColumns="False"
> > BorderWidth="1px" BackColor="LightGoldenrodYellow" CellPadding="2"
> > GridLines="None">
> > <SelectedItemStyle ForeColor="GhostWhite"
> > BackColor="DarkSlateBlue"></SelectedItemStyle>
> > <AlternatingItemStyle
> > BackColor="PaleGoldenrod"></AlternatingItemStyle>
> > <HeaderStyle Font-Bold="True" BackColor="Tan"></HeaderStyle>
> > <FooterStyle BackColor="Tan"></FooterStyle>
> > <Columns>
> > <asp:HyperLinkColumn Text="Edit"
> > DataNavigateUrlField="Employee_Id"
> >

> DataNavigateUrlFormatString="MaintCourseCode.aspx? parmCourseCode={0}&amp;usr
> Action=Edt">
> > <HeaderStyle Font-Bold="True"></HeaderStyle>
> > </asp:HyperLinkColumn>
> > <asp:HyperLinkColumn Text="Delete"
> > DataNavigateUrlField="Employee_Id"
> >

> DataNavigateUrlFormatString="MaintCourseCode.aspx? parmCourseCode={0}&amp;usr
> Action=Del">
> > <HeaderStyle Font-Bold="True"></HeaderStyle>
> > </asp:HyperLinkColumn>
> > <asp:TemplateColumn HeaderText="Status">
> > <HeaderStyle Font-Bold="True"></HeaderStyle>
> > <ItemStyle HorizontalAlign="Left"></ItemStyle>
> > <ItemTemplate>
> > <div align="center">
> > <IMG SRC='<%# Container.DataItem("mypicture") %>'
> > Border="0">
> > <br>
> > <%# (Container.DataItem("mypicture")) %>
> > </div>
> > </ItemTemplate>
> > </asp:TemplateColumn>
> > <asp:BoundColumn DataField="Phone" SortExpression="Phone"
> > HeaderText="Phone"></asp:BoundColumn>
> > <asp:BoundColumn DataField="Name" SortExpression="Name"
> > HeaderText="Name"></asp:BoundColumn>
> > <asp:BoundColumn DataField="Employee_Id"
> > SortExpression="Employee_Id"
> > HeaderText="Employee_Id"></asp:BoundColumn>
> > </Columns>
> > <PagerStyle HorizontalAlign="Center"
> > ForeColor="DarkSlateBlue" BackColor="PaleGoldenrod"></PagerStyle>
> > </asp:datagrid></div>

 
Reply With Quote
 
naikpalak naikpalak is offline
Junior Member
Join Date: Apr 2009
Posts: 1
 
      04-30-2009
Was anyone able to fix this. I am having similar issues with my windows app. I am using Datagridbuttoncolumnstyles to display an edit button in one of the columns in my datagrid. Any time I insert rows from my database and bind it to this datagird, i get System.Byte[] as text on my button instead i would like to have "Edit" as my text. I have the header text as:
buttonColStyle.HeaderText = _dataSet.Tables["OPAServices"].Columns[i].ColumnName;
and it shows "Edit" but not on my display???
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
New to ASP: Read SQL user table output results in a table on a ASP webpage matching search field Yas ASP .Net 0 08-01-2007 04:02 PM
how to read image from sql server to show in a image =?Utf-8?B?am9l?= ASP .Net 2 07-24-2006 01:33 PM
Show image from SQL Image Field ? Bob ASP General 2 08-22-2003 07:02 PM
Re: SQL statement working in SQL Server but not in .aspx.cs page David Browne ASP .Net 0 08-21-2003 10:43 PM
Re: SQL statement working in SQL Server but not in .aspx.cs page William \(Bill\) Vaughn ASP .Net 0 08-21-2003 10:41 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57