Get the Site Name for the item

Nov 28, 2007 at 3:27 PM
Is there no way to get and display the site name, im rolling up news from a site collection which includes about 12 sites and them Im displaying say 14 items in 2 columns but Id like to be able to put next to each item the name of the site it came from or the list name it came from.

Many Thanks

Marcus
Jan 3, 2008 at 7:09 AM
Hi,
For doing this create one more property in itemWrap.cs file. In this property create an SpWEb object and get title of current site being traversed by using SPWEBObject.Title property.
e.g. public string SiteName
{
get
{
if (this.ListItem == null || this.ListItem.File == null)
{
return -1;
}
else
{ SPWEb obj=new SPWEb(Siteurl);if(obj!=null){return obj.Title;

}
}
}

ADD custom column for thsi in datatable,and add the value of this property in each row.


Amit