Wednesday 31 October 2012

sharepoint add lookup field programmatically-client object model

ADD LOOKUP FIELD PROGRAMMATICALLY SHAREPOINT 2010-CLIENT OBJECT MODEL


Insert the following namespace

using Microsoft.SharePoint;
using Microsoft.SharePoint.Client;

Use the following code.

ClientContext ccsite;
   List listobj;
   List listobj_lookup;            //Object for lookup list
   ListItemCollection _icoll; 
  public MainPage()
      {
           InitializeComponent();

           ccsite = new ClientContext(ApplicationContext.Current.Url);
           ccsite.Load(ccsite.Web);
           listobj = ccsite.Web.Lists.GetByTitle("ListName");
           listobj_lookup= ccsite.Web.Lists.GetByTitle("ListName");     // (LookUp List)
           ccsite.Load(listobj);
         
            CamlQuery qry = new CamlQuery();
            qry.ViewXml = "";

            _icoll_lookup= listobj_lookup.GetItems(qry);
            ccsite.Load(_icoll_lookup);          
            ccsite.ExecuteQueryAsync(new ClientRequestSucceededEventHandler(success), null);
       }

 private void success(object sender,ClientRequestSucceededEventArgs arg)
    {
         Dispatcher.BeginInvoke(datacon);
     }

private void datacon()
   {
            //Geting List Item Record ID of lookup value
            int recordID = 0;
            foreach (ListItem item in _icoll_lookup)
            {
                if (Convert.ToString(item["ListItmeValue"]) == "YourString")
                { recordID = Convert.ToInt32(item["ID"]); }
            }

            //For insert Lookup value
            ListItem litem = listobj.AddItem(new ListItemCreationInformation());
            FieldLookupValue lookupobj = new FieldLookupValue { LookupId = recordID };
            litem["ColumnName1"] = lookupobj as FieldLookupValue;
            litem.Update();
            ccsite.ExecuteQueryAsync(new ClientRequestSucceededEventHandler(succed), null);
    }

private void succed(object sender, ClientRequestSucceededEventArgs arg)
    { }
</ div>

ADD MULTIPLE LOOKUP FIELD PROGRAMMATICALLY SHAREPOINT 2010-CLIENT OBJECT MODEL

Insert the following namespace

using Microsoft.SharePoint;
using Microsoft.SharePoint.Client;
ClientContext ccsite;
   List listobj;
   List listobj_lookup;            //Object for lookup list
   ListItemCollection _icoll; 
  public MainPage()
      {
           InitializeComponent();

           ccsite = new ClientContext(ApplicationContext.Current.Url);
           ccsite.Load(ccsite.Web);
           listobj = ccsite.Web.Lists.GetByTitle("ListName");
           listobj_lookup= ccsite.Web.Lists.GetByTitle("ListName");     // (LookUp List)
           ccsite.Load(listobj);
         
            CamlQuery qry = new CamlQuery();
            qry.ViewXml = "<View/>";

            _icoll_lookup= listobj_lookup.GetItems(qry);
            ccsite.Load(_icoll_lookup);          
            ccsite.ExecuteQueryAsync(new ClientRequestSucceededEventHandler(success), null);
       }

 private void success(object sender,ClientRequestSucceededEventArgs arg)
    {
         Dispatcher.BeginInvoke(datacon);
     }

private void datacon()
   {
            //Geting Multiple List Item Record ID of lookup value
             int[] recordID=new int[_icoll_lookup.Count];
             int count=0;
            foreach (ListItem item in _icoll_lookup)
            {
                if (Convert.ToString(item["ListItmeValue"]) == "YourString")
                   {
                    recordID[count] = Convert.ToInt32(item["ID"]);
                    count++; 
                     }
            }

            //For insert Multiple Lookup value
           ListItem litem = listobj.AddItem(new ListItemCreationInformation());
           FieldLookupValue[] lookupobj = new FieldLookupValue[count];
            for (int i = 0; i < count; i++)
            {
                lookupobj[i] = new FieldLookupValue{ LookupId = recordID[i] };
            }
            litem["ColumnName"] = lookupobj as FieldLookupValue[];
            litem.Update();
            ccsite.ExecuteQueryAsync(new ClientRequestSucceededEventHandler(succed), null);
    }

private void succed(object sender, ClientRequestSucceededEventArgs arg)
  {
   } 

Tuesday 30 October 2012

Asp.net Static Charts




using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.DataVisualization.Charting;
using System.Data;

namespace StaticChart
{
    public partial class _Default : System.Web.UI.Page
    {
       
        protected void Page_Load(object sender, EventArgs e)
        {
            Chart1.DataSource = GetchartData();
            Chart1.DataBind();

        }

        public  DataTable GetchartData()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("Month", typeof(string));
            dt.Columns.Add("Date", typeof(DateTime));
            dt.Columns.Add("Sales1", typeof(int));
            dt.Columns.Add("Sales2", typeof(int));
            dt.Columns.Add("Sales3", typeof(int));

            DataRow row = dt.NewRow();
            row["Date"] = new DateTime(2006, 1, 1);
            row["Month"] = "January";
            row["Sales1"] = 100;
            row["Sales2"] = 100;
            row["Sales3"] = 200;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Date"] = new DateTime(2006, 2, 1);
            row["Month"] = "February";
            row["Sales1"] = 200;
            row["Sales2"] = 110;
            row["Sales3"] = 170;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Date"] = new DateTime(2006, 3, 1);
            row["Month"] = "March";
            row["Sales1"] = 300;
            row["Sales2"] = 140;
            row["Sales3"] = 290;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Date"] = new DateTime(2006, 4, 1);
            row["Month"] = "April";
            row["Sales1"] = 100;
            row["Sales2"] = 60;
            row["Sales3"] = 100;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Date"] = new DateTime(2006, 5, 1);
            row["Month"] = "May";
            row["Sales1"] = 300;
            row["Sales2"] = 160;
            row["Sales3"] = 120;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Date"] = new DateTime(2006, 6, 1);
            row["Month"] = "June";
            row["Sales1"] = 200;
            row["Sales2"] = 120;
            row["Sales3"] = 190;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Date"] = new DateTime(2006, 7, 1);
            row["Month"] = "June";
            row["Sales1"] = 200;
            row["Sales2"] = 160;
            row["Sales3"] = 220;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Date"] = new DateTime(2006, 8, 1);
            row["Month"] = "August";
            row["Sales1"] = 220;
            row["Sales2"] = 80;
            row["Sales3"] = 120;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Date"] = new DateTime(2006, 9, 1);
            row["Month"] = "September";
            row["Sales1"] = 270;
            row["Sales2"] = 200;
            row["Sales3"] = 100;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Date"] = new DateTime(2006, 10, 1);
            row["Month"] = "October";
            row["Sales1"] = 300;
            row["Sales2"] = 230;
            row["Sales3"] = 190;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Date"] = new DateTime(2006, 11, 1);
            row["Month"] = "November";
            row["Sales1"] = 260;
            row["Sales2"] = 100;
            row["Sales3"] = 200;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Date"] = new DateTime(2006, 12, 1);
            row["Month"] = "December";
            row["Sales1"] = 320;
            row["Sales2"] = 190;
            row["Sales3"] = 270;
            dt.Rows.Add(row);

            return dt;

        }
    }
}
   <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="StaticChart._Default" %>

<%@ Register assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI.DataVisualization.Charting" tagprefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body style="height: 328px">
    <form id="form1" runat="server">
    <div>
        <asp:Panel ID="Panel1" runat="server" Height="391px">
              <asp:Chart ID="Chart1" runat="server" Height="371px" Width="642px">
                <series>
                    <asp:Series Name="Series1" XValueMember="Month" 
                        YValueMembers="Sales1">
                    </asp:Series>
                    <asp:Series Name="Series2" XValueMember="Month" 
                        YValueMembers="Sales2">
                    </asp:Series>
                    <asp:Series Name="Series3" XValueMember="Month" 
                         YValueMembers="Sales3">
                    </asp:Series>
                </series>
                <chartareas>
                    <asp:ChartArea Name="ChartArea1">
                    </asp:ChartArea>
                </chartareas>
            </asp:Chart>
        </asp:Panel>
    </div>
    </form>
</body>
</html>


Asp.net Dynamic Charts


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.DataVisualization.Charting;
using System.Data;

namespace DynamicChart
{
    public partial class _Default : System.Web.UI.Page
    {
       
        protected void Page_Load(object sender, EventArgs e)
        {
            Chart ch = new Chart();
            ChartArea ca = new ChartArea();
            ch.ChartAreas.Add(ca);
            ch.Width = 400;
            ch.Height = 500;
           
            ch.BackColor = System.Drawing.Color.AliceBlue;
            ch.DataBind();
            Series s1 = new Series();
            s1.Color = System.Drawing.Color.Blue;
            s1.ChartType = SeriesChartType.Bar;
            s1.XValueMember = "Month";
            s1.YValueMembers = "Sales1";

            Series s2 = new Series();
            s2.Color = System.Drawing.Color.Red;
            s2.ChartType = SeriesChartType.Bar;
            s2.XValueMember = "Month";
            s2.YValueMembers = "Sales2";

            Series s3 = new Series();
            s3.Color = System.Drawing.Color.Green;
            s3.ChartType = SeriesChartType.Bar;
            s3.XValueMember = "Month";
            s3.YValueMembers = "Sales3";

            ch.Series.Add(s1);
            ch.Series.Add(s2);
            ch.Series.Add(s3);
            ch.DataSource = GetchartData();
            ch.DataBind();
            Panel1.Controls.Add(ch);

        }

        public  DataTable GetchartData()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("Month", typeof(string));
            dt.Columns.Add("Date", typeof(DateTime));
            dt.Columns.Add("Sales1", typeof(int));
            dt.Columns.Add("Sales2", typeof(int));
            dt.Columns.Add("Sales3", typeof(int));

            DataRow row = dt.NewRow();
            row["Date"] = new DateTime(2006, 1, 1);
            row["Month"] = "January";
            row["Sales1"] = 100;
            row["Sales2"] = 100;
            row["Sales3"] = 200;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Date"] = new DateTime(2006, 2, 1);
            row["Month"] = "February";
            row["Sales1"] = 200;
            row["Sales2"] = 110;
            row["Sales3"] = 170;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Date"] = new DateTime(2006, 3, 1);
            row["Month"] = "March";
            row["Sales1"] = 300;
            row["Sales2"] = 140;
            row["Sales3"] = 290;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Date"] = new DateTime(2006, 4, 1);
            row["Month"] = "April";
            row["Sales1"] = 100;
            row["Sales2"] = 60;
            row["Sales3"] = 100;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Date"] = new DateTime(2006, 5, 1);
            row["Month"] = "May";
            row["Sales1"] = 300;
            row["Sales2"] = 160;
            row["Sales3"] = 120;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Date"] = new DateTime(2006, 6, 1);
            row["Month"] = "June";
            row["Sales1"] = 200;
            row["Sales2"] = 120;
            row["Sales3"] = 190;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Date"] = new DateTime(2006, 7, 1);
            row["Month"] = "June";
            row["Sales1"] = 200;
            row["Sales2"] = 160;
            row["Sales3"] = 220;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Date"] = new DateTime(2006, 8, 1);
            row["Month"] = "August";
            row["Sales1"] = 220;
            row["Sales2"] = 80;
            row["Sales3"] = 120;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Date"] = new DateTime(2006, 9, 1);
            row["Month"] = "September";
            row["Sales1"] = 270;
            row["Sales2"] = 200;
            row["Sales3"] = 100;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Date"] = new DateTime(2006, 10, 1);
            row["Month"] = "October";
            row["Sales1"] = 300;
            row["Sales2"] = 230;
            row["Sales3"] = 190;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Date"] = new DateTime(2006, 11, 1);
            row["Month"] = "November";
            row["Sales1"] = 260;
            row["Sales2"] = 100;
            row["Sales3"] = 200;
            dt.Rows.Add(row);

            row = dt.NewRow();
            row["Date"] = new DateTime(2006, 12, 1);
            row["Month"] = "December";
            row["Sales1"] = 320;
            row["Sales2"] = 190;
            row["Sales3"] = 270;
            dt.Rows.Add(row);

            return dt;

        }
    }
}
   <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="DynamicChart._Default" %>

<%@ Register assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI.DataVisualization.Charting" tagprefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body style="height: 328px">
    <form id="form1" runat="server">
    <div>
        <asp:Panel ID="Panel1" runat="server" Height="391px">
        </asp:Panel>
    </div>
    </form>
</body>
</html>


CSS Menu





<html>
<head>
<title>CSS Menu</title>
<style >
        #navigation li ul
        {
             list-style: none;
             margin: 0;
             padding: 0;    
             visibility:hidden;
             position: absolute;
             z-index: 99999;
             visibility:hidden;
        }
        ul#navigation li:hover > ul
        {
             visibility:visible;
        }
        
       ul#navigation 
       {
            float:left;
            border-right:1px solid #c4dbe7;
       }

        ul#navigation li ul li a
       {
         width:100px;
         height:10px;
         font-size:8px;
         border-right:1px solid #C2C2C2;
        
       background-image: linear-gradient(bottom, rgb(32,217,217) 23%, rgb(59,255,245) 62%);
background-image: -o-linear-gradient(bottom, rgb(32,217,217) 23%, rgb(59,255,245) 62%);
background-image: -moz-linear-gradient(bottom, rgb(32,217,217) 23%, rgb(59,255,245) 62%);
background-image: -webkit-linear-gradient(bottom, rgb(32,217,217) 23%, rgb(59,255,245) 62%);
background-image: -ms-linear-gradient(bottom, rgb(32,217,217) 23%, rgb(59,255,245) 62%);

background-image: -webkit-gradient(
 linear,
 left bottom,
 left top,
 color-stop(0.23, rgb(32,217,217)),
 color-stop(0.62, rgb(59,255,245))
);

     }
    

     ul#navigation li a 
     {
     padding:10px 25px;
     color:#616161;
     display:inline-block;
     text-decoration:none;
     border-right:1px solid #fff;
     border-left:1px solid #C2C2C2;
     border-top:1px solid #fff;

background-image: linear-gradient(bottom, rgb(32,217,217) 23%, rgb(59,255,245) 62%);
background-image: -o-linear-gradient(bottom, rgb(32,217,217) 23%, rgb(59,255,245) 62%);
background-image: -moz-linear-gradient(bottom, rgb(32,217,217) 23%, rgb(59,255,245) 62%);
background-image: -webkit-linear-gradient(bottom, rgb(32,217,217) 23%, rgb(59,255,245) 62%);
background-image: -ms-linear-gradient(bottom, rgb(32,217,217) 23%, rgb(59,255,245) 62%);

background-image: -webkit-gradient(
 linear,
 left bottom,
 left top,
 color-stop(0.23, rgb(32,217,217)),
 color-stop(0.62, rgb(59,255,245))
);
   
}

     ul#navigation ul 
      {
          top: 45px;
          left: 1px;
          width:100px;
       }

      ul#navigation li a:hover 
       {
           background-image: linear-gradient(bottom, rgb(135,245,245) 23%, rgb(185,250,246) 62%);
           background-image: -o-linear-gradient(bottom, rgb(135,245,245) 23%, rgb(185,250,246) 62%);
           background-image: -moz-linear-gradient(bottom, rgb(135,245,245) 23%, rgb(185,250,246) 62%);
           background-image: -webkit-linear-gradient(bottom, rgb(135,245,245) 23%, rgb(185,250,246) 62%);
           background-image: -ms-linear-gradient(bottom, rgb(135,245,245) 23%, rgb(185,250,246) 62%);

           background-image: -webkit-gradient(
                              linear,
                              left bottom,
                              left top,
                              color-stop(0.23, rgb(135,245,245)),
                              color-stop(0.62, rgb(185,250,246))
                              );
             color:#282828;
   
          }

       ul#navigation  li 
          {
           display:inline;
           font-size:12px;
           font-weight:bold;
           margin:0;
           padding:0;
           float:left;
           position:relative;
           border-top:1px solid #c4dbe7;
           border-bottom:2px solid #c4dbe7;
           }
    </style>
 </head>
 <body>
 <ul id="navigation">
        <li><a href="http://www.dotnetstadium.com">DotnetStadium</a></li>
        <li><a href="#">Services</a>
        <ul>
           <li><a href="#">WebSite Development</a></li>
           <li><a href="#">N/W Management</a></li>
           <li><a href="#">Software Management</a></li>
           <li><a href="#">Product Consultation</a></li>
        </ul>    
        </li>
         <li><a href="www.dotnetstadium.com">Downloads</a>
         <ul>
         <li><a href="#">softwares</a></li>
         <li><a href="#">games</a></li>
         <li><a href="#">themes</a></li>
         </ul>
         </li>
    </ul>
 </body>
 </html>

Saturday 29 September 2012

THIS VIEW CANNOT BE DISPLAYED BECAUSE THE NUMBER OF LOOKUP AND WORKFLOW STATUS COLUMNS IT CONTAINS EXCEEDS THE THRESHOLD (8) ENFORCED BY THE ADMINISTRATOR


You may have this kind of error when you open a list.

this view cannot be displayed because the number of lookup and workflow status columns it contains exceeds the threshold (8) enforced by the administrator

The problem occurs because the number of managed metadata fields on a library exceeds the number permitted in the SharePoint environment configuration.  When this error occurs it can cause the SharePoint web services can refuse to return documents.

To solve this problem do the following


Setps:

1)Go to Central Administrator --> Manage Web Applications.

2)Select required Web Application --> Click General Settings and select Resource throttling



3)Go to the List View Lookup Threshold property and increase as required.




Wednesday 26 September 2012

Asp.net Sql Connection Insert command

Method1

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using sql = System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
   sql.SqlConnection sqlcon;
   sql.SqlCommand sqlcmd;
   string Emp_Name,Emp_ID,Salary;
   string connstr;

   protected void Page_Load(object sender, EventArgs e)
   {
        Emp_Name = "Raj";         Emp_ID = "3421";         Salary = "20000";

       connstr = "Data Source=SRV4;Initial Catalog=Employee;Integrated Security=True";

       sqlcon = new sql.SqlConnection(connstr);
       sqlcmd = sqlcon.CreateCommand();
       sqlcmd.CommandText = "INSERT INTO EmployeeDetails VALUES ('" + Emp_Name+ "','"

Emp_ID + "','" + Salary + "')";
       sqlcon.Open();
       sqlcmd.ExecuteNonQuery();
       sqlcon.Close();


   }
}



Method2(Prefered Method)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using sql = System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
   sql.SqlConnection sqlcon;
   sql.SqlCommand sqlcmd;
    string Emp_Name,Emp_ID,Salary;
   string connstr;

   protected void Page_Load(object sender, EventArgs e)
   {
        Emp_Name = "Raj";         Emp_ID = "3421";         Salary = "20000";

       connstr = "Data Source=SRV4;Initial Catalog=Employee;Integrated Security=True";

       sqlcon = new sql.SqlConnection(connstr);
       sqlcmd = sqlcon.CreateCommand();
       sqlcmd.CommandText = "INSERT INTO EmployeeDetails VALUES (@name,@id,@salary)";
       sqlcmd.Parameters.AddWithValue("@name", Emp_Name);
       sqlcmd.Parameters.AddWithValue("@id", Emp_ID);
       sqlcmd.Parameters.AddWithValue("@salary", Salary);

       sqlcon.Open();
       sqlcmd.ExecuteNonQuery();
       //inside for loop use below code
       sqlcmd.Parameters.Clear();
       sqlcon.Close();
   }

}

Friday 21 September 2012

Sharepoint 2010 web or subsite Backup Restore


BACKUP AND RESTORE OF A WEB OR SUBSITE IN SHAREPOINT 2010


Backup web:


        Open sharepoint power shell. and type the following  command on your power shell

Import-spweb <fullurl which u want to backup> -path <location>  

Restore web:


        Open sharepoint power shell. and type the following  command on your power shell

Export-spweb <fullurl where u want to restore> -path <location>

How to use Sharepoint2010 List Template



    You can create a list template and restore it in any places as a list.

CREATE A LIST TEMPLATE:


       Do it in following way.

(Open your site->)list->list settings->save list as a template

and save the template at any place you want.


RESTORE THE TEMPLATE TO LIST:


      Do it in following way

(open your site)->site actions->site settings->gallaris->list templates->(document->upload document)

     And after that

Site Actions->more Options->list->(there you can find your template name.And select that template name)

Tuesday 18 September 2012

Silverlight LineSeries Datapoint & Polyline Styling

Get Microsoft Silverlight
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace LineChart
{
    public partial class MainPage : UserControl
    {
        List<EmployeeChart> employeechart;
        public MainPage()
        {
            InitializeComponent();

           
            employeechart = new List<EmployeeChart>();

            employeechart.Add(new EmployeeChart()
            {
                employeename = "Emp1",
                sickleave = 7,
                casualleave=9
            });
            employeechart.Add(new EmployeeChart()
            {
                employeename = "Emp2",
                sickleave = 5,
                casualleave=3
            });
            
    employeechart.Add(new EmployeeChart()
            {
                employeename = "Emp3",
                sickleave = 6,
                 casualleave=8
            });
             employeechart.Add(new EmployeeChart()
             {
                 employeename = "Emp4",
                 sickleave = 8,
                  casualleave=7
             });
             employeechart.Add(new EmployeeChart()
             {
                 employeename = "Emp5",
                 sickleave = 9,
                  casualleave=7
             });
   
            chart1.DataContext = employeechart;
        }

        public class EmployeeChart
        {
            public string employeename { get; set; }
            public int sickleave { get; set; }
            public int casualleave { get; set; }
        }

      
    }
}


          
        
  
        
        
    
        
        
            
            
            
            
        
        
         
         
                                       
           
           
                 
     
  
   
         
          
                                       
             
             
             
     
  
        
  
  
    


Friday 14 September 2012

Silverlight Datagrid Get Data on Selcetion

Get Microsoft Silverlight

The cs code is as follows
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace grid
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();

            List&ltdata&gt employeedetails = new List&ltdata&gt();

            employeedetails.Add(new data() 
                 { Name="Latha",
                   ID="3456",
                   Salary="12000" 
                  });
            employeedetails.Add(new data() 
                  { Name = "Geetha", 
                    ID = "3457", 
                    Salary = "13000" 
                  });
            employeedetails.Add(new data() 
                  { Name = "Mohan", 
                    ID = "3458", 
                    Salary = "14000" 
                  });
            employeedetails.Add(new data() 
                  { Name = "Ram", 
                    ID = "3459", 
                    Salary = "15000" 
                  });
            employeedetails.Add(new data() 
                  { Name = "Sundar", 
                    ID = "34570",
                    Salary="16000" });

            dataGrid1.ItemsSource = employeedetails;
        }

        public class data
        {
            public string Name { get; set; }
            public string ID { get; set; }
            public string Salary { get; set; }
        }

        private void dataGrid1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DataGrid datagrid = sender as DataGrid;
            DataGridColumn column = datagrid.Columns[1];

            FrameworkElement fe = column.GetCellContent(dataGrid1.SelectedItem);
            FrameworkElement result = GetParent(fe, typeof(DataGridCell));

            if (result != null)
            {
                DataGridCell cell = (DataGridCell)result;
                TextBlock tx = cell.Content as TextBlock;
                label1.Content = tx.Text;
            }
        }

        private FrameworkElement GetParent(FrameworkElement child, Type targetType)
        {
            object parent = child.Parent;
            if (parent != null)
            {
                if (parent.GetType() == targetType)
                {
                    return (FrameworkElement)parent;
                }
                else
                {
                    return GetParent((FrameworkElement)parent, targetType);
                }
            }
            return null;
        } 
    }
}


The XAML code is as follows



    
        
        
        
    


Silverlight Bubble Chart Datapoint Styling

Get Microsoft Silverlight
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace BubbleChart
{
    public partial class MainPage : UserControl
    {
        List<EmployeeChart> employeechart;
        public MainPage()
        {
            InitializeComponent();

           
            employeechart = new List<EmployeeChart>();

            employeechart.Add(new EmployeeChart()
            {
                employeename = "Emp1",
                sickleave = 7,
                casualleave=9
            });
            employeechart.Add(new EmployeeChart()
            {
                employeename = "Emp2",
                sickleave = 5,
                casualleave=3
            });
            
    employeechart.Add(new EmployeeChart()
            {
                employeename = "Emp3",
                sickleave = 6,
                 casualleave=8
            });
             employeechart.Add(new EmployeeChart()
             {
                 employeename = "Emp4",
                 sickleave = 8,
                  casualleave=7
             });
             employeechart.Add(new EmployeeChart()
             {
                 employeename = "Emp5",
                 sickleave = 9,
                  casualleave=7
             });
   
            chart1.DataContext = employeechart;
        }

        public class EmployeeChart
        {
            public string employeename { get; set; }
            public int sickleave { get; set; }
            public int casualleave { get; set; }
        }
    }
}

    
        
        
  
        
    
        
        
            
            
   
   
        
        
         
         
                                       
           
           
                 
     
  
   
         
          
                                       
             
             
             
     
  
        
  
  
    


Friday 31 August 2012

Silverlight DataGrid DataBinding

Get Microsoft Silverlight

The XAML Code is as Follows



    
        
        
        
    




The CS code is as follows

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace grid
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();

            List employeedetails = new List();

            employeedetails.Add(new data() { Name="Latha",ID="3456",Salary="12000" });
            employeedetails.Add(new data() { Name = "Geetha", ID = "3457", Salary = "13000" });
            employeedetails.Add(new data() { Name = "Mohan", ID = "3458", Salary = "14000" });
            employeedetails.Add(new data() { Name = "Ram", ID = "3459", Salary = "15000" });
            employeedetails.Add(new data() { Name = "Sundar", ID = "34570",Salary="16000" });

            dataGrid1.ItemsSource = employeedetails;
        }

        public class data
        {
            public string Name { get; set; }
            public string ID { get; set; }
            public string Salary { get; set; }
        }
       
    }
}


Thursday 16 August 2012

How to add Quick Launchbar in sharepoint Programatically


Step1

First you need to add the following name space

using Microsoft.SharePoint;
using Microsoft.SharePoint.Navigation;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.Publishing;

Step 2

And next include the following code in your web part

protected void Page_Load(object sender, EventArgs e)
        {
            using (var site = new SPSite(SPContext.Current.Site.Url))
            {
                var rootPubweb = PublishingWeb.GetPublishingWeb(site.RootWeb);
                var subwebs = rootPubweb.GetPublishingWebs();
                site.RootWeb.AllowUnsafeUpdates = true;

                string[] headnode = { "link1", "link2"};
                SPNavigationNodeCollection nodes =  site.RootWeb.Navigation.QuickLaunch;
                for (int j = 0; j < headnode.Length; j++)
                {
                    SPNavigationNode navNode = new SPNavigationNode(headnode[j], "http://www.google.com", false);
                    nodes.AddAsFirst(navNode);
                }
        }

Step 3


Finally deploy the web part. and insert the web part in your site& reload the page. this link will appear in your site.

Thursday 9 August 2012

Bing Map Latitude Longitude

Get Microsoft Silverlight

The  main  page cs code  for this  project  is  as follows

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using Microsoft.Maps;
using Microsoft.Maps.MapControl;

namespace slbng
{
    public partial class MainPage : UserControl
    {
       
        double x, y;
        Location location;
        public MainPage()
        {
            InitializeComponent();
           
        }
       
        private void BingMap_MouseMove(object sender, MouseEventArgs e)
        {
           x= e.GetPosition(BingMap).X;
           y = e.GetPosition(BingMap).Y;

           Point viewportpoint = e.GetPosition(BingMap);

           BingMap.TryViewportPointToLocation(viewportpoint, out location);
           LatTB.Text = location.Latitude.ToString();
           LongTB.Text = location.Longitude.ToString();
               
        }
    }
}


The  Xaml  code  for  the  project is as follows