SharePoint - How To add link in individual items on name field in Sharepoint Design

Asked By MD on 11-Feb-12 08:47 PM

Hi,

i am trying to get list items from one site collection and display that data into other page, lets say which is in top level site page. so i am getting list items by using soap service.  but when i want to insert link on name field, it doesn't give me default view url into desiger. so my question is how can i add link for each individual items on name field. Should i create new column in xpath expression. Please let me know what will be the best approach that will be appreciated.

Thanks in advance

D Company replied to MD on 12-Feb-12 12:48 AM
Hello Friend,

if i could understand it clear than you want to modify a Data View in your intranet Web application to link .

Create or open a Data View of a SharePoint list, and then switch to Design view.
 Select the field value in the column in which you want to offer the hyperlink, and then click the arrow in the upper-right corner to show the Common xsl:value-of Tasks list.In the Format as drop-down list, click Hyperlink. If the Confirm dialog box appears, click Yes. Enter the URL. or text.

this is just a normal approach if all you want to do dynamically or using code that you can do using VS also.

traverse through each item of particular field and edit the items and add hyperlink to the text, than call acceptchage() method, this u can do under RunWithElevated priviliges.

or in SP designer use edit view of list items

Hope its clear to you!!
Regards
D
kalpana aparnathi replied to MD on 12-Feb-12 05:07 AM
hi,

Try this below example code for your solution


using ( SPSite siteCollection = new SPSite( "http://moss.litwareinc.com" ) ) {
  using ( SPWeb web = siteCollection.OpenWeb( "docs" ) ) {
    SPList list = web.Lists["Sample"];
 
    //link to the file
 
    StringBuilder builder = new StringBuilder();
 
    using ( TextReader reader = new StreamReader( @"C:\linktodocumenttemplate.txt" ) ) {
      builder.Append( reader.ReadToEnd() );
    }
 
    //replace string template with values
    builder.Replace( "{0}", fileLinkUrl );
     
    //should change the name of the .aspx file per item
    SPFile file = list.RootFolder.Files.Add( "link_title.aspx", UTF8Encoding.UTF8.GetBytes(builder.ToString()));
 
    //set list item properties
    SPListItem item = file.Item;
    item["Content Type"] = "Link to a Document";
    SPFieldUrlValue itemUrl = new SPFieldUrlValue();
    itemUrl.Description = "From sample code";
    itemUrl.Url = fileLinkUrl;
    item["URL"] = itemUrl;
    //persist changes
    item.Update();
  }
}


Thanks,
MD replied to D Company on 12-Feb-12 10:52 AM
Hi D Company,

Thanks for your reply. As you said i can use Common xsl:value-of Tasks and from drop down can choose hyper link and then url or text. But problem is when i am choosing Data field as m:properties/d:name its giving me this url https://intranet.org/global/jol/SitePages/introduction.aspx, it doesn't let me go anywhere. but i need to get the folling url by choosing Data field https://intranet.org/global/jol/abm/Pages/introduction.aspx. As you already know i am trying to get list item from other site collection by using web service in sharepoint designer. please help me out if you have any more idea. how can i achive this functionality for each field in the column.

Thanks
MD
D Company replied to MD on 12-Feb-12 12:26 PM
Sorry for delay reply.

In this case u have to fetch text only, and than create dynamically link control(through code)and than assign the text to it.

regards
D
MD replied to D Company on 12-Feb-12 01:05 PM
Hi D,

appreciate for your reply. could you help me details? actually i am new in sharepoint. so at first how can i fetch text, and then how can i create link control though code and assaign the text to it. should i use x path expression?

Thanks
MD
Somesh Yadav replied to MD on 13-Feb-12 06:40 AM
Hi friend dont worry just go through the below link  it is very clearly explained about how to add link in individual items on name field in sharepoint designer,

http://office.microsoft.com/en-us/sharepoint-designer-help/customize-data-views-and-forms-using-sharepoint-designer-HA101631678.aspx

I hope it helps you.
MD replied to Somesh Yadav on 13-Feb-12 12:39 PM
Hello My friend,

i haven' seen anything related with, how to add link in individual items on name field in sharepoint designer. can u provide details with this?

Thanks