Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 23rd, 2005, 02:37 PM
Authorized User
 
Join Date: Aug 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default Displaying images in a datagrid

Hello Everyone,

Does anyone know how to make a DataGid that would include images? I guess the real question is can an image be attached in a database such as Microsoft Access. If so how do you go about and do it. I am under the assumption that you would create a datafield and the contents of the cells would give a path to where the images are stored.

Doing that,would you know how to set up an ItemTemplate in a DataGrid to interpet that information and display the image in the browser.

Please help.

thanks,

Ray

 
Old September 25th, 2005, 09:44 AM
Authorized User
 
Join Date: Aug 2005
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can attach images into datagrid. Just use <itemtemplate> and you can get the picture there with normal image tag

 
Old September 26th, 2005, 10:25 AM
Authorized User
 
Join Date: Aug 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Lofa,

Thank you for your replies. Can give me a code example. I am still having a hard time to understand this.

thanks,

Ray

 
Old September 26th, 2005, 12:58 PM
Authorized User
 
Join Date: Aug 2005
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can put a tag like <img width="50" height="50" src="../images/listings/details/
<%# dsListingRooms.FieldValue("ListingRoomPic",Contain er) %>"> between <itemtemplate></itemtemplate>

example
<asp:DataGrid AllowPaging="false"
  AllowSorting="False"
  AutoGenerateColumns="false"
  CellPadding="3"
  CellSpacing="0"
        DataKeyField="PID"
  DataSource="<%# kom.DefaultView %>" id="Komp_edit"
  runat="server"
  ShowFooter="false"
  ShowHeader="true"
  onUpdateCommand="kom.OnDataGridUpdate"
  onEditCommand="kom.OnDataGridEdit"
  onCancelCommand="kom.OnDataGridCancel"
  onDeleteCommand="kom.OnDataGridDelete"
  onItemDataBound="kom.OnDataGridItemDataBound"
>
            <HeaderStyle HorizontalAlign="center" BackColor="#E8EBFD" ForeColor="#3D3DB6" Font-Name="Tw Cen MT" Font-Bold="true" Font-Size="smaller" />
            <ItemStyle BackColor="#F2F2F2" Font-Name="Tw Cen MT" Font-Size="smaller" />
            <AlternatingItemStyle BackColor="#E5E5E5" Font-Name="Tw Cen MT" Font-Size="smaller" />
            <FooterStyle HorizontalAlign="center" BackColor="#E8EBFD" ForeColor="#3D3DB6" Font-Name="Tw Cen MT" Font-Bold="true" Font-Size="smaller" />
            <PagerStyle BackColor="white" Font-Name="Tw Cen MT" Font-Size="smaller" />
            <Columns>
            <asp:TemplateColumn HeaderText="Manufactor"
        Visible="True">
              <ItemTemplate><%# kom.FieldValue("Tillverkare", Container) %> </ItemTemplate>
              <EditItemTemplate>
                <asp:TextBox ID="tillverkare" runat="server" Columns="13" Text='<%# kom.FieldValue("Tillverkare", Container) %>'></asp:TextBox>
              </EditItemTemplate>
            </asp:TemplateColumn>
            <asp:TemplateColumn HeaderText="Product<br>name"
        Visible="True">
              <ItemTemplate><%# kom.FieldValue("ProduktNamn", Container) %> </ItemTemplate>
              <EditItemTemplate>
              <asp:TextBox runat="server" ID="produktnamn" Columns="13" Text='<%# kom.FieldValue("ProduktNamn", Container) %>'></asp:TextBox>
              </EditItemTemplate>
            </asp:TemplateColumn>
            <asp:TemplateColumn HeaderText="Category"
        Visible="True">
              <ItemTemplate><%# kom.FieldValue("Kat", Container) %></ItemTemplate>
              <EditItemTemplate>
                <asp:DropDownList DataSource="<%# kategori.DefaultView %>" DataTextField="Kat" DataValueField="CATID" ID="CATID" runat="server"
                            SelectedIndex='<%# (kom.FieldValue("CATID",Container)-1) %>'></asp:DropDownList>
              </EditItemTemplate>
            </asp:TemplateColumn>
            <asp:TemplateColumn HeaderText="Pic Orginal<br>(Details Page)"
        Visible="True">
              <ItemTemplate><%# kom.FieldValue("OrginalName", Container) %></ItemTemplate>
              <EditItemTemplate>
                <asp:DropDownList DataSource="<%# PicOrginal.DefaultView %>" DataTextField="OrginalName" DataValueField="PicOrginal" ID="PicOrginal" runat="server"
                 SelectedIndex='<%# (kom.FieldValue("PicOrginal",Container)-1) %>'></asp:DropDownList>
              </EditItemTemplate>
            </asp:TemplateColumn>
            <asp:TemplateColumn HeaderText="Pic Thumbnail<br>(Main Page)"
        Visible="True">
              <ItemTemplate><%# kom.FieldValue("ThumbName", Container) %></ItemTemplate>
              <EditItemTemplate>
                <asp:DropDownList DataSource="<%# PicThumb.DefaultView %>" DataTextField="ThumbName" DataValueField="PicThumb" ID="PicThumb" runat="server"
                 SelectedIndex='<%# (kom.FieldValue("PicThumb",Container)-1) %>'></asp:DropDownList>
              </EditItemTemplate>
            </asp:TemplateColumn>
            <asp:TemplateColumn HeaderText="Description"
        Visible="True">
              <ItemTemplate><%# kom.FieldValue("Beskrivning", Container) %> </ItemTemplate>
              <EditItemTemplate>
                <asp:TextBox ID="Beskrivning" runat="server" TextMode="MultiLine" Columns="12" Rows="5" Text='<%# kom.FieldValue("Beskrivning", Container) %>' ></asp:TextBox>
              </EditItemTemplate>
            </asp:TemplateColumn>
            <asp:TemplateColumn HeaderText="Description 2"
        Visible="True">
              <ItemTemplate><%# kom.FieldValue("Beskrivning2", Container) %> </ItemTemplate>
              <EditItemTemplate>
                <asp:TextBox ID="Beskrivning2" runat="server" TextMode="MultiLine" Columns="12" Rows="5" Text='<%#kom.FieldValue("Beskrivning2", Container) %>'></asp:TextBox>
              </EditItemTemplate>
            </asp:TemplateColumn>
            <asp:TemplateColumn HeaderText="Unit Price"
        Visible="True">
              <ItemTemplate>
                <div align="right"><%# Double.Parse(kom.FieldValue("Styckpris", Container)).ToString("C") %></div>
              </ItemTemplate>
              <EditItemTemplate>
                <asp:TextBox ID="Styckpris" runat="server" Columns="7" Text='<%# Double.Parse(kom.FieldValue("Styckpris", Container)).ToString("F") %>'></asp:TextBox>
              </EditItemTemplate>
            </asp:TemplateColumn>
            <asp:TemplateColumn HeaderText="Offer"
        Visible="True">
              <ItemTemplate><%# kom.FieldValue("rea", Container) %></ItemTemplate>
              <EditItemTemplate>
                <asp:TextBox ID="Rea" runat="server" Columns="4" Text='<%#kom.FieldValue("rea",Container) %>'> </asp:TextBox>
  Write Yes Or No </EditItemTemplate>
            </asp:TemplateColumn>
            <asp:ButtonColumn
        ButtonType="PushButton"
        CommandName="Delete"
        HeaderText="Delete"
        Text="Delete"
        Visible="True"/>
<asp:EditCommandColumn
        ButtonType="PushButton"
        CancelText="Cancel"
        EditText="Edit"
        HeaderText="Edit"
        UpdateText="Update"
        Visible="True"/>
</Columns>
          </asp:DataGrid>
this is created with Dreamweaver but the itemtemplate and edititemtemplate works on pure asp.net same like in dreamweaver






Similar Threads
Thread Thread Starter Forum Replies Last Post
displaying images chandan121 JSP Basics 0 May 1st, 2008 09:59 PM
Displaying images...... kethireddy435 ASP.NET 2.0 Professional 0 September 16th, 2007 09:25 PM
Images not displaying Penn_Clark Dreamweaver (all versions) 3 February 21st, 2006 12:59 PM
Displaying Images in a DataGrid RichardOrmiston ASP.NET 1.0 and 1.1 Basics 1 December 13th, 2005 01:13 PM
Displaying images inbox Classic ASP XML 2 May 4th, 2005 03:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.