Connecting Tech Pros Worldwide Forums | Help | Site Map

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

J Sahoo
Guest
 
Posts: n/a
#1: Nov 18 '05
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
[color=blue][color=green][color=darkred]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>[/color][/color][/color]

<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>
bruce barker
Guest
 
Posts: n/a
#2: Nov 18 '05

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


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" <sahoo@mississippi.org> wrote in message
news:248795d.0407060843.6d0f9abd@posting.google.co m...[color=blue]
> 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
>[color=green][color=darkred]
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>[/color][/color]
>
> <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"
>[/color]
DataNavigateUrlFormatString="MaintCourseCode.aspx? parmCourseCode={0}&amp;usr
Action=Edt">[color=blue]
> <HeaderStyle Font-Bold="True"></HeaderStyle>
> </asp:HyperLinkColumn>
> <asp:HyperLinkColumn Text="Delete"
> DataNavigateUrlField="Employee_Id"
>[/color]
DataNavigateUrlFormatString="MaintCourseCode.aspx? parmCourseCode={0}&amp;usr
Action=Del">[color=blue]
> <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>[/color]


J Sahoo
Guest
 
Posts: n/a
#3: Nov 18 '05

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


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" <nospam_brubar@safeco.com> wrote in message news:<OPdb6w3YEHA.3596@tk2msftngp13.phx.gbl>...[color=blue]
> 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" <sahoo@mississippi.org> wrote in message
> news:248795d.0407060843.6d0f9abd@posting.google.co m...[color=green]
> > 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
> >[color=darkred]
> > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>[/color]
> >
> > <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"
> >[/color]
> DataNavigateUrlFormatString="MaintCourseCode.aspx? parmCourseCode={0}&amp;usr
> Action=Edt">[color=green]
> > <HeaderStyle Font-Bold="True"></HeaderStyle>
> > </asp:HyperLinkColumn>
> > <asp:HyperLinkColumn Text="Delete"
> > DataNavigateUrlField="Employee_Id"
> >[/color]
> DataNavigateUrlFormatString="MaintCourseCode.aspx? parmCourseCode={0}&amp;usr
> Action=Del">[color=green]
> > <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>[/color][/color]
Closed Thread