Generally while we are inserting Values to Hyper Link Data Type in a Custom List we have two Options one is for the Hyper link "Value" and the Other is for the "Description".
The Description will appear at UI . After clicking on it , It will navigate to Certain Page.

The following example will demonstrate , how we will achieve this Programatically.
We Can achieve this by two ways:
Method 1:
SPList oList= oWeb.Lists.TryGetList("ListName");
if (oList!= null)
{
SPListItem oListItem= oList.Items.Add();
oListItem["Column1"] = "Some Value";
oListItem["HyperlinkColumnName"] = "http://www.google.com, Google";
oListItem.Update();
}
Method 2:
SPList oList= oWeb.Lists.TryGetList("ListName");
if (oList!= null)
{
SPListItem oListItem= oList.Items.Add();
SPFieldUrlValue hyper = new SPFieldUrlValue();
hyper.Description = "Google";
hyper.Url = "http://www.google.com";
oListItem["Column1"] = "Some Value";
oListItem["HyperlinkColumnName"] = hyper;
oListItem.Update();
}
The Description will appear at UI . After clicking on it , It will navigate to Certain Page.

The following example will demonstrate , how we will achieve this Programatically.
We Can achieve this by two ways:
Method 1:
SPList oList= oWeb.Lists.TryGetList("ListName");
if (oList!= null)
{
SPListItem oListItem= oList.Items.Add();
oListItem["Column1"] = "Some Value";
oListItem["HyperlinkColumnName"] = "http://www.google.com, Google";
oListItem.Update();
}
Method 2:
SPList oList= oWeb.Lists.TryGetList("ListName");
if (oList!= null)
{
SPListItem oListItem= oList.Items.Add();
SPFieldUrlValue hyper = new SPFieldUrlValue();
hyper.Description = "Google";
hyper.Url = "http://www.google.com";
oListItem["Column1"] = "Some Value";
oListItem["HyperlinkColumnName"] = hyper;
oListItem.Update();
}
0 comments:
Post a Comment