Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Updating list item

  Asked By: Tyrel    Date: Oct 08    Category: Sharepoint    Views: 1224

I am trying to update a list item programmatically, and have yet
another question. Is it possible to update the link and description of
a hyperlink column. (It is in a document library).

Specifically, I want to add a link that says "view report" and have the
link be "http://reports/whatever".

Here's what I got. This sets the URL and text to the link. I cannot
figure out how to make the text to the link say "view report."

Dim listItem As SPListItem = upFile.Item
listItem.Item("Report Link") = "http://reports/"




2 Answers Found

Answer #1    Answered By: Himanshu Gohil     Answered On: Oct 08

Here is the full code in C#. The line to note is:

newItem["URL"] = "http://vmksdc/, NewHome";

Where URL is the field containing the link  information and NewHome is
the text  that you want displayed.

SPSite mySite = SPControl.GetContextSite(Context);

mySite.RootWeb.AllowUnsafeUpdates = true;
SPList myList = mySite.RootWeb.Lists["Links"];

SPListItemCollection myLIC = myList.Items;

SPListItem newItem = myLIC.Add();

newItem["URL"] = "http://vmksdc/, NewHome";


catch (Exception e)
string str = e.Message;

Answer #2    Answered By: Faith Delgado     Answered On: Oct 08

I found the answer ...

I needed to append a comma, followed by a space, then append the
text to display. See below.

listItem.Item("Report Link") = "http://reports/" & ", " & "View

Don't forget the comma after the space ", "!

Didn't find what you were looking for? Find more on Updating list item Or get search suggestion and latest updates.