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

Discussion in 'ASP .Net' started by J Sahoo, Jul 6, 2004.

  1. J Sahoo

    J Sahoo Guest

    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>
    J Sahoo, Jul 6, 2004
    #1
    1. Advertising

  2. J Sahoo

    bruce barker Guest

    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:...
    > 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>
    bruce barker, Jul 6, 2004
    #2
    1. Advertising

  3. J Sahoo

    J Sahoo Guest

    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:...
    > > 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>
    J Sahoo, Jul 7, 2004
    #3
  4. J Sahoo

    naikpalak

    Joined:
    Apr 30, 2009
    Messages:
    1
    Palak Naik

    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.ColumnName;
    and it shows "Edit" but not on my display???
    naikpalak, Apr 30, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. William \(Bill\) Vaughn
    Replies:
    0
    Views:
    437
    William \(Bill\) Vaughn
    Aug 21, 2003
  2. David Browne
    Replies:
    0
    Views:
    447
    David Browne
    Aug 21, 2003
  3. =?Utf-8?B?Um9ic29uIENhcnZhbGhvIE1hY2hhZG8=?=

    How to resize an image from SQL IMAGE field

    =?Utf-8?B?Um9ic29uIENhcnZhbGhvIE1hY2hhZG8=?=, Sep 10, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    4,431
    Hermit Dave
    Sep 10, 2004
  4. =?Utf-8?B?am9l?=
    Replies:
    2
    Views:
    3,374
    Winista
    Jul 24, 2006
  5. Yas
    Replies:
    0
    Views:
    474
Loading...

Share This Page