is it possible to display image in gridview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • imranabdulaziz
    New Member
    • Dec 2006
    • 29

    is it possible to display image in gridview

    Dear All,

    I am using asp.net2.0, sql 2005
    I am storing Image url in database. through that url i would like to show images in gridview
    I want to know is it possible to show images in gridview.
    Please guide me or give me some useful link.
    Thanks
  • gwtech
    New Member
    • Jul 2007
    • 3

    #2
    First off store your pics in a folder!
    Just save the name in the db. Saving pics to the db can bloat it quickly.
    [please refrain from advertising your services on this forum]

    This code is the Master Detail with photo for my system.

    <asp:DetailsVie w ID="DetailsView 1" runat="server" AutoGenerateRow s="False" DataKeyNames="P ictureID"
    DataSourceID="S qlDataSource1" Height="50px" Width="885px" CellPadding="4" ForeColor="#333 333" GridLines="None ">
    <Fields>
    <asp:BoundFie ld DataField="Pict ureID" HeaderText="Pic tureID" InsertVisible=" False"
    ReadOnly="True" SortExpression= "PictureID" />
    <asp:BoundFie ld DataField="Name " HeaderText="Nam e" SortExpression= "Name" />
    <asp:BoundFie ld DataField="Loca tion" HeaderText="Loc ation" SortExpression= "Location" />
    <asp:BoundFie ld DataField="Stat us" HeaderText="Sta tus" SortExpression= "Status" />
    <asp:ImageFie ld DataImageUrlFie ld="PictureURL " HeaderText="Pho to">
    </asp:ImageField>
    <asp:TemplateFi eld HeaderText="Dog Info" SortExpression= "DogInfo">
    <EditItemTempla te>
    <asp:TextBox ID="DogInfo" runat="server" Rows="8" Text='<%# Bind("DogInfo") %>' TextMode="Multi Line"
    Width="456px"></asp:TextBox>
    </EditItemTemplat e>
    <InsertItemTemp late>
    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("DogInfo") %>'></asp:TextBox>
    </InsertItemTempl ate>
    <ItemStyle Width="600px" />
    <ItemTemplate >
    <asp:Label ID="Label1" runat="server" Text='<%# Bind("DogInfo") %>'></asp:Label>
    </ItemTemplate>
    </asp:TemplateFie ld>
    <asp:BoundFie ld DataField="URLS ource" HeaderText="Lin k" SortExpression= "URLSource" />
    <asp:BoundFie ld DataField="Date Uploaded" HeaderText="Cre ated On" ReadOnly="True"
    SortExpression= "DateUpload ed" />
    <asp:BoundFie ld DataField="Cont act" HeaderText="Con tact" SortExpression= "Contact" />
    <asp:BoundFie ld DataField="UEma il" HeaderText="Con tact Email" SortExpression= "UEmail" />
    <asp:BoundFie ld DataField="Phon e" HeaderText="Pho ne" SortExpression= "Phone" />
    <asp:BoundFie ld DataField="File Size" HeaderText="Fil eSize" ReadOnly="True" SortExpression= "FileSize" />
    <asp:BoundFie ld DataField="Upda ted" HeaderText="Upd ated" ReadOnly="True" SortExpression= "Updated" />
    <asp:CommandFie ld ShowEditButton= "True" ButtonType="But ton" />
    </Fields>
    <FooterStyle BackColor="#990 000" Font-Bold="True" ForeColor="Whit e" />
    <CommandRowStyl e BackColor="#FFF FC0" Font-Bold="True" />
    <RowStyle BackColor="#FFF BD6" ForeColor="#333 333" />
    <PagerStyle BackColor="#FFC C66" ForeColor="#333 333" HorizontalAlign ="Center" />
    <FieldHeaderSty le BackColor="#FFF F99" Font-Bold="True" />
    <HeaderStyle BackColor="#990 000" Font-Bold="True" ForeColor="Whit e" />
    <AlternatingRow Style BackColor="Whit e" />
    </asp:DetailsView ><br />

    <asp:GridView ID="GridView1" runat="server" AllowPaging="Tr ue" AllowSorting="T rue"
    AutoGenerateCol umns="False" DataKeyNames="P ictureID" DataSourceID="P icturesDataSour ce"
    Width="885px" PageSize="4">
    <Columns>
    <asp:CommandFie ld ShowDeleteButto n="True" ShowSelectButto n="True" ButtonType="But ton" />
    <asp:BoundFie ld DataField="Pict ureID" HeaderText="ID" InsertVisible=" False"
    ReadOnly="True" SortExpression= "PictureID" />
    <asp:BoundFie ld DataField="Name " HeaderText="Dog 's Name" SortExpression= "Name" />
    <asp:BoundFie ld DataField="DogI nfo" HeaderText="Dog 's Info" SortExpression= "DogInfo" />
    <asp:ImageFie ld DataImageUrlFie ld="PictureURL " HeaderText="Pho to">
    </asp:ImageField>
    <asp:BoundFie ld DataField="Loca tion" HeaderText="Loc ation" SortExpression= "Location" />
    <asp:BoundFie ld DataField="Cont act" HeaderText="Con tact" SortExpression= "Contact" />
    <asp:BoundFie ld DataField="Stat us" HeaderText="Sta tus" SortExpression= "Status" />
    <asp:BoundFie ld DataField="Upda ted" HeaderText="Upd ated (Date)" SortExpression= "Updated" />
    </Columns>
    </asp:GridView>
    Last edited by kenobewan; Jul 21 '07, 01:39 PM. Reason: Advertising removed

    Comment

    Working...