try
{
var context = new LinqDemoDataContext(SPContext.Current.Web.Url);
string strTitle = string.Empty;
string strHyperlink = string.Empty;
string strCompleteUrl = string.Empty;
var links = from a in context.Links
select new
{
strHyperlink=a.URL.Substring(0,a.URL.IndexOf(",")),
strTitle=a.URL.ToString().Substring(a.URL.IndexOf(',')+1)
};
sgvLinks = new SPGridView();
sgvLinks.Attributes.Add("RunAt", "Server");
sgvLinks.AutoGenerateColumns = false;
this.Controls.Add(sgvLinks);
HyperLinkField hlnk = new HyperLinkField();
hlnk.HeaderText = "Hyperlink";
hlnk.DataTextField = "strTitle";
hlnk.DataNavigateUrlFields = new string[] { "strHyperlink" };
sgvLinks.Columns.Add(hlnk);
if (links.Count() > 0)
{
sgvLinks.DataSource = links;
sgvLinks.DataBind();
}
}
catch (Exception ex)
{
writer.Write(ex.ToString());
}
No comments:
Post a Comment