using System;
using System.Runtime.InteropServices;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using System.Security;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;
using System.Collections.Specialized;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using System.Configuration;
using System.Data;
using System.Web.UI.HtmlControls;
[assembly: AllowPartiallyTrustedCallers]
namespace CustomWebServiceResult
{
[Guid("bec42463-9e42-4ead-92ae-4723cf3f2c02")]
public class CustomWebServiceResult : System.Web.UI.WebControls.WebParts.WebPart
{
GridView ServiceGridView;
string strError = string.Empty;
localhost.Service s = new localhost.Service();
public CustomWebServiceResult()
{
}
protected override void Render(HtmlTextWriter writer)
{
writer.Write(strError);
try
{
ServiceGridView.RenderControl(writer);
}
catch (Exception ex)
{
writer.Write(ex.ToString());
}
}
protected override void CreateChildControls()
{
try
{
ServiceGridView = new GridView();
ServiceGridView.ID = "ServiceGridView";
ServiceGridView.AutoGenerateColumns = false;
BoundField bTitle = new BoundField();
bTitle.HeaderText = "Task Name";
bTitle.DataField = "Title";
ServiceGridView.Columns.Add(bTitle);
BoundField bStatus = new BoundField();
bStatus.HeaderText = "Task Status";
bStatus.DataField = "Status";
ServiceGridView.Columns.Add(bStatus);
BoundField bPriority = new BoundField();
bPriority.HeaderText = "Task Priority";
bPriority.DataField = "Priority";
ServiceGridView.Columns.Add(bPriority);
BoundField bStartDate = new BoundField();
bStartDate.HeaderText = "Task Start Date";
bStartDate.DataField = "StartDate";
ServiceGridView.Columns.Add(bStartDate);
s.UseDefaultCredentials = true;
ServiceGridView.DataSource = s.getTasks();
ServiceGridView.DataBind();
this.Controls.Add(ServiceGridView);
}
catch (Exception ex)
{
strError += ex.ToString();
}
}
}
}
Wednesday, November 30, 2011
Using a custom webservice in a webpart
Category:
SharePoint 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment