Displaying Images in a GridView or DataList...

Last post 01-10-2008 1:51 AM by srijaya_ramaraju@yahoo.com. 4 replies.

Sort Posts:

  • Displaying Images in a GridView or DataList...

    01-08-2008, 8:35 AM
    • Loading...
    • apollolax123
    • Joined on 09-29-2006, 2:54 PM
    • Florida, USA
    • Posts 91

    Does anyone know of a way or control that will allow a GridView or DataList that will allow my Images folder to be my datasource. This would act as a "slideshow" if  you will. I have looked into the AJAX slideshow, but did not dive into it too deeply. Basically, I have given my client the ability to upload pictures to his Images folder and he wants to be able to view them in some sort of way.

    I am using Fireworks to complie an album into a flash slideshow, but when my client adds a new picture i do not want to have to do it every time.

    Can anyone point me in the right direction or does anyone have a solution?

    Thanks!

    If you get an answer to your question, please mark it as 'Answer' Smile


    www.lymanlax.com | www.possumslax.com
  • Re: Displaying Images in a GridView or DataList...

    01-08-2008, 8:46 AM
    • Loading...
    • impathan
    • Joined on 07-12-2007, 10:12 AM
    • Ahmedabad
    • Posts 787

    apollolax123:
    I am using Fireworks to complie an album into a flash slideshow, but when my client adds a new picture i do not want to have to do it every time.
     

    Get it. LightBox Javascript to view image 

    Click on 'Mark as Answer' if this post is helpful.

    ImranKhan pathan
  • Re: Displaying Images in a GridView or DataList...

    01-08-2008, 9:39 AM
    • Loading...
    • apollolax123
    • Joined on 09-29-2006, 2:54 PM
    • Florida, USA
    • Posts 91

    and this attaches to the Images folder so you can add images dynamically without having to recomplie pics in Fireworks?

    If you get an answer to your question, please mark it as 'Answer' Smile


    www.lymanlax.com | www.possumslax.com
  • Re: Displaying Images in a GridView or DataList...

    01-10-2008, 1:24 AM
    Answer

    Hi:

      You can just use AJAX SlideShowExtender. Here's a sample (create a Web Application project and add a new asmx item to this project):

      The aspx:

     <asp:Image ID="Image1" runat="server" />

      <cc1:SlideShowExtender PlayInterval="1000"    TargetControlID="Image1" AutoPlay="true" Loop="true"  ID="SlideShowExtender1" runat="server"
                SlideShowServiceMethod="GetSlides"  SlideShowServicePath="WebService.asmx">
            </cc1:SlideShowExtender>

      The asmx web service:

    using System;
    using System.Collections;
    using System.Web;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using System.IO;
    /// <summary>
    /// Summary description for WebService
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    [System.Web.Script.Services.ScriptService]
    public class WebService : System.Web.Services.WebService
    {
        [System.Web.Services.WebMethod]

        [System.Web.Script.Services.ScriptMethod]


        public AjaxControlToolkit.Slide[] GetSlides()
        {
            DirectoryInfo d = new DirectoryInfo(Server.MapPath("images"));
            FileInfo[] fi = d.GetFiles();
            ArrayList list = new ArrayList();
            for (int i = 0; i < fi.Length; i++)
            {
                if (fi[i].Extension == ".jpg")
                {
                    list.Add(fi[i].Name);
                }
            }

            AjaxControlToolkit.Slide[] result = new AjaxControlToolkit.Slide[list.Count];

            for (int i = 0; i < result.Length; i++)
            {
                result[i] = new AjaxControlToolkit.Slide("images/" + list[i].ToString(), i.ToString(), i.ToString());
            }

            return result;


        }


        public WebService()
        {

            //Uncomment the following line if using designed components
            //InitializeComponent();
        }

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }

    }

     

      And you need a directory called images under the root direcotory of the web site. Above code will work for all jpg images. You can modify the logic to meet your needs.

    Regards

     

    Sincerely,
    Allen Chen
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: Displaying Images in a GridView or DataList...

    01-10-2008, 1:51 AM

    plz check this thread

    http://forums.asp.net/t/1201749.aspx

    Thank u

    Baba 

    Please remember to click "Mark as Answer" on this post if it helped you.
     

    Thank u

    Baba

    Please remember to click "Mark as Answer" on this post if it helped you.
Page 1 of 1 (5 items)
Microsoft Communities
Page view counter