Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. format a string in Data Repeater (list array as a data source)

format a string in Data Repeater (list array as a data source)

Scheduled Pinned Locked Moved ASP.NET
sysadmindata-structuresquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Farhad Eft
    wrote on last edited by
    #1

    Hi I have a repeater control and I used array list as the data source. This array has only one field and it's a number to be used as the identification. how can i format the image server control url in my data repeater to show the right image with right Id! thank you so much Here is my source code:

        List lstID = new List();
    
        var query2 = context.Offers.Select(p => new { itemId = p.OfferId }).Skip(1).Take(6).ToList();
    
        foreach (var item in query2)
        {
            lstID.Add(item.itemId);
        }
    
        RepeaterOthers.DataSource = lstID;
        RepeaterOthers.DataBind();
    

    and here is where i'd like to use that offerId: <asp:Repeater ID="RepeaterOthers" runat="server"> <ItemTemplate> <asp:Image ID="ImageFront" runat="server" ImageUrl="~/images/{0}.jpg" /> </ItemTemplate> </asp:Repeater>

    P 1 Reply Last reply
    0
    • F Farhad Eft

      Hi I have a repeater control and I used array list as the data source. This array has only one field and it's a number to be used as the identification. how can i format the image server control url in my data repeater to show the right image with right Id! thank you so much Here is my source code:

          List lstID = new List();
      
          var query2 = context.Offers.Select(p => new { itemId = p.OfferId }).Skip(1).Take(6).ToList();
      
          foreach (var item in query2)
          {
              lstID.Add(item.itemId);
          }
      
          RepeaterOthers.DataSource = lstID;
          RepeaterOthers.DataBind();
      

      and here is where i'd like to use that offerId: <asp:Repeater ID="RepeaterOthers" runat="server"> <ItemTemplate> <asp:Image ID="ImageFront" runat="server" ImageUrl="~/images/{0}.jpg" /> </ItemTemplate> </asp:Repeater>

      P Offline
      P Offline
      Parwej Ahamad
      wrote on last edited by
      #2

      I haven't tested but this should be work. If doesn't work the let me know. Thanks

      Parwej Ahamad

      F 1 Reply Last reply
      0
      • P Parwej Ahamad

        I haven't tested but this should be work. If doesn't work the let me know. Thanks

        Parwej Ahamad

        F Offline
        F Offline
        Farhad Eft
        wrote on last edited by
        #3

        thank u so much man! it worked! recently i lost my old projects files that i programmed before now i know nothing without it! lol

        P 1 Reply Last reply
        0
        • F Farhad Eft

          thank u so much man! it worked! recently i lost my old projects files that i programmed before now i know nothing without it! lol

          P Offline
          P Offline
          Parwej Ahamad
          wrote on last edited by
          #4

          Your Welcome!

          Parwej Ahamad

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups