Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

enter image description here

whats the problem?

123 should be with bild1.gif and second image with bild2.gif

share|improve this question
    
Duplicate of this one: sharepoint.stackexchange.com/questions/57792/… –  Nadeem Yousuf Jan 24 '13 at 9:34
    
yea i know , but noone is helping me –  Martin Jan 24 '13 at 9:35
1  
That is no reason to add another question - it just reduces the value of the site while annoying the people who might be able to help you. Please edit your original question to improve it if you want to increase the chance of getting an answer. –  SPDoctor Jan 24 '13 at 13:06

1 Answer 1

took me some time to understand what you were looking for lol bad on my part but i think i have the right solution for you ;) I've gone through and come up with this code, this link helped me to figure out what was going on :)

http://support.microsoft.com/kb/929259

ok i think this should work for you

    SPQuery query = new SPQuery();
    query.Query = string.Format("<OrderBy><FieldRef Name='Modified' Ascending='FALSE'></FieldRef></OrderBy>");
    query.RowLimit = 10;
    query.IncludeAttachmentUrls = true;
    SPListItemCollection items = list.GetItems(query);

    Repeater1.DataSource = items;
    Repeater1.DataBind();

that is fine and is called after the databound, so its doing the binding and then adding thoes links. To ammend the data whilst its being bound you need to call the itemdatabound event like so:

private List<string> arrayList = new List<string>;

protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) 
{ 
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) 
    { 
          HyperLink hp;
          foreach (SPListItem item in list.Items)
          {

              foreach (string currentAttachmentUrl in item.Attachments)
              { 
                  if (!arrayList.Contains(currentAttachmentUrl)) 
                  { 
                      hp = new HyperLink(); 
                      hp.ID = e.Item.ItemIndex.ToString(); 
                      hp.Text = item.Attachments.UrlPrefix + currentAttachmentUrl; 
                      hp.NavigateUrl = item.Attachments.UrlPrefix + currentAttachmentUrl; 
                      arrayList.Add(currentAttachmentUrl); 
                  }
              }
          }

        // add to the repeater 
        e.Item.Controls.Add(hp); 

    } 

}

to call the event above you need to add this to the repeater:

<asp:Repeater ID="Repeater1" OnItemDataBound="Repeater1_ItemDataBound" runat="server">

I've taken the code that I've done and added it into the new event, your calling the new event where you create the repeater. This should do the trick :)

EDIT

I've just amended the code above, it checks the current item in the repeater against the current item in the list, if its the same than it will do the code (hyperlink), please let me know the result as you might need to tweak the if function as i dont know what the two values are weather e.Item.ItemIndex starts at 0 or 1 and same with the other :)

hope it helps :)

share|improve this answer
    
When you add the first news with attachment, it doesnt show it in the interface. When you create a second one, the second one doesn't show up, but the first appears. And when you create a third news, third one doesnt show, but the second and first ones attachment appears. BUT(!). The itemid doesnt following the current news –  Martin Jan 24 '13 at 23:54
    
iv ammended the code, you need to check the values by debugging the line if (e.Item.ItemIndex == item.ID-1) and see what values are going in. i put -1 as i belive the item.id starts at 1 rather than 0 like the index msdn.microsoft.com/en-us/library/… –  ali Sharepoint Jan 25 '13 at 8:56
    
With -1 it show ok But the attachment doesn't follow with the uploaded values. it only stays in place For example Name:Martin Age:22 Attachment:hello.jpg i want that the attachment to be together with Martin and Age and not only that it will display the attachment –  Martin Jan 25 '13 at 10:21
    
Namely,attachments ​​do not accompany their news –  Martin Jan 25 '13 at 10:29
    
item.id starts at 1 its true and index at 0 but the problem is like above here , that the attachment doesnt follow with the added item to list it only stays in place in the interface –  Martin Jan 25 '13 at 10:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.