Friday, September 19, 2008

Create Dashboard using KPI List in WSS

Procedure to Create Dashboard using KPI List in WSS
· Install SMARTPART tool in SharePoint
· To activate SMARTPART select Site Settings àSite Collection Features à Activate
· Create list in your WSS site
· Create one image document library and add images in it.
· Create a new web application in visual studio
· Insert a web user control in the design window then insert a grid view control inside the web user control.
· Add the following reference in your web application Windows SharePoint Services under .NET Tab ‘Share Point Services’
· Add the following namespaces in your code Microsoft.SharePoint, Microsoft.SharePoint.WebControls
· Add the following code in source window of the usercontrol.aspx file

[asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"]
[Columns]
[asp:BoundField DataField="User Name" HeaderText="User" /]
[asp:BoundField DataField="Status" HeaderText="Status" /]
[asp:ImageField DataImageUrlField="Status Image" HeaderText="Status Image"]
[/asp:ImageField]
[/Columns]
[/asp:GridView]
· Add the following code in code window of the usercontrol.aspx.cs file
protected void Page_Load(object sender, EventArgs e)
{
GridView1.DataSource = GetData();
GridView1.DataBind();
}
DataTable GetData()
{

DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("User Name", typeof(string)));
dt.Columns.Add(new DataColumn("Status", typeof(string)));
dt.Columns.Add(new DataColumn("Status Image", typeof(string)));
//SPSite thisSite1 = new SPSite("http://joseph-wss:65455/default.aspx");
SPSite thisSite1 = SPControl.GetContextSite(HttpContext.Current);
SPWeb siteopen = thisSite1.OpenWeb();
SPListItemCollection kpilist = siteopen.Lists["User Status"].Items;
foreach (SPListItem ss in kpilist.List.Items)
{
if (ss["Status"].ToString() == "Active")
{
DataRow dr = dt.NewRow();
dr["User Name"] = ss["User Name"].ToString(); ;
dr["Status"] = ss["Status"].ToString();
dr["Status Image"] = ResolveUrl("~/KPI%20Status%20Images/Active.JPG");
dt.Rows.Add(dr);
}
else if (ss["Status"].ToString() == "Inactive")
{
DataRow dr = dt.NewRow();
dr["User Name"] = ss["User Name"].ToString(); ;
dr["Status"] = ss["Status"].ToString();
dr["Status Image"] = ResolveUrl("~/KPI%20Status%20Images/Inactive.JPG");
dt.Rows.Add(dr);
}
else if (ss["Status"].ToString() == "Hold")
{
DataRow dr = dt.NewRow();
dr["User Name"] = ss["User Name"].ToString(); ;
dr["Status"] = ss["Status"].ToString();
dr["Status Image"] = ResolveUrl("~/KPI%20Status%20Images/Hold.JPG");
dt.Rows.Add(dr);
}

}
return dt;
}
· Add the following code inside the assemblies tag in webconfig(C:\Inetpub\wwwroot\wss\VirtualDirectories\65455) file

· Create one folder in our port number with the following name “UserControls” then paste the two files that is UserControl.aspx and UserControl.aspx.cs
· Then select Site Settings à Edit Page à Click Add Web Part à Check the Smart Part Click Ok.
· Click Edit à Modify Shared Web Part
· Select the user control from the list from the tab “User control to display” then click Apply and click ok.
· Now you can see the Dashboard in your website

No comments: