About Me

My photo
Muthupet, TamilNadu, India
SharePoint 2010

Saturday, June 2, 2012

SharePoint Interview Question

Question: -What is SharePoint?
Answer: – SharePoint 2010 is a platform where user can share Data, Collaborate
and people can also take this platform and customized platform as per their
requirements.
Question: – What are the two different products in SharePoint 2010?
Answer: – SharePoint 2010 has basically two different products namely SharePoint
Foundation 2010 and SharePoint Server 2010.
SharePoint Foundation 2010 is basically a free version.
SharePoint Server 2010 is basically a paid version.
Question: -How to create a simple Website in SharePoint 2010?
Answer: – In order to create a Website in SharePoint 2010, we need to use
SharePoint 2010 Central Administration tool. As soon as you click on SharePoint
2010 Central Administration tool it will ask for credential do put your
credential and you will directed to the SharePoint 2010 Central Administration
screen. Now from the Application Management screen click on Manage web
applications, as soon as you click on Manage web applications a new window will
open, now from the top most left of the screen click on New menu, again a new
window will pop-up of Create New Web Application which enables you to create new
web application.
Question: – How to create Users and Allocates permissions to the Users?
Answer: -Permission management is a three steps process as follows.
Step1: -Create Users.
Step2: – Create Permissions.
Step3: – Link the Users with the Permissions.
In order to create a User’s and Allocate permissions Click on Site Actions
located on the top link bar and then click on Site Permissions.Now, under the
Edit tab, click on Grant Permissions. Later, In the Users/group field, enter the
user’s name, choose the permissions you wish the user to have under Give
Permission, and then click on OK.
Question: – How tocreate or deploy Web parts in SharePoint 2010?
Answer: -Web part: – It is a reusable functionality, which can be inserted on
the web pages and can be configured by the end users. In order to create a web
part, go to Visual Studio and create a new project > select SharePoint tab >
select Visual Web Part > select on which local web site you want to deploy the
web part > click on Validate and Click finish.
Now, in order to deploy the project just go to > Solution Explorer > select your
project > Right click on it > just select deploy.

Gird view (RowDataBound)

ascx(c#)


<table cellpadding="0" cellspacing="0">
    <tr>
        <td> Announcement Details
        </td>
    </tr>
    <tr>
        <td>
            <asp:GridView ID="grdAnnouncements" runat="server" AutoGenerateColumns="false"
                onrowdatabound="grdAnnouncements_RowDataBound">
                <Columns>
                    <asp:TemplateField>
                        <ItemTemplate>
                        <asp:HyperLink ID="lnkTitle" runat="server" Text='<%#Bind("Title") %>' NavigateUrl='<%#Bind("EncodedAbsUrl") %>' ></asp:HyperLink>
                <asp:Label ID="lblItemID" runat="server" Text='<%#Bind("ID") %>'></asp:Label>
                              <asp:Label ID="lblFileDirRef" runat="server" Text='<%#Bind("FileDirRef") %>'></asp:Label>
                        </ItemTemplate>
                        <HeaderTemplate>
                            Title
                        </HeaderTemplate>
                    </asp:TemplateField>
                     <asp:TemplateField>
                        <ItemTemplate>
                            <asp:Label ID="lblTitle" runat="server" Text='<%#Bind("Body") %>'></asp:Label>
                        </ItemTemplate>
                        <HeaderTemplate>
                            Body
                        </HeaderTemplate>
                    </asp:TemplateField>
           
                </Columns>
            </asp:GridView>
        </td>
    </tr>
</table>
<asp:Label ID="lblError" runat="server" ForeColor="Red"></asp:Label>

SPDataQuery Example(current login user,RowDataBound)

ascx.cs

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using System.Data;
namespace SampleSPDataQuery.CorporateAnnouncements
{
    public partial class CorporateAnnouncementsUserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                BindGridDetails();
           
        }
        public void BindGridDetails()
        {
            try
            {
                SPUser oCuser= SPContext.Current.Web.CurrentUser ; 
                using (SPSite osite = new SPSite(SPContext.Current.Site.ID))
                {
                    using (SPWeb oweb = osite.OpenWeb())
                    {
                        SPSiteDataQuery ositeDataQuery = new SPSiteDataQuery();
                        ositeDataQuery.Lists = "<Lists ServerTemplate='104'/>";
                        ositeDataQuery.Query = "<Where><Eq><FieldRef Name='user' /><Value Type='User'>" + oCuser.LoginName + "</Value></Eq></Where>";
                        ositeDataQuery.Webs = "<Webs Scope='SiteCollection' />";
                        ositeDataQuery.ViewFields = "<FieldRef Name='Title' /><FieldRef Name='ID' /><FieldRef Name='Body' /><FieldRef Name='FileRef' /><FieldRef Name='EncodedAbsUrl' /><FieldRef Name='FileDirRef' />";
                        ositeDataQuery.RowLimit = 10;
                        DataTable odt = oweb.GetSiteData(ositeDataQuery);
                        grdAnnouncements.DataSource = odt;
                        grdAnnouncements.DataBind();
                    }
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
        }
        protected void grdAnnouncements_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Label lblFileDirRef = (Label)e.Row.FindControl("lblFileDirRef");
                Label lblItemID = (Label)e.Row.FindControl("lblItemID");
                HyperLink lnkTitle = (HyperLink)e.Row.FindControl("lnkTitle");
                lnkTitle.NavigateUrl = lnkTitle.NavigateUrl + lblFileDirRef.Text.Split('#')[1] + "/DispForm.aspx?ID=" + lblItemID.Text ;
                lblFileDirRef.Visible = false;
                lblItemID.Visible = false;
            }
        }
       
       
   
    }
}

sharepoint list and grid

c#(aspx.cs)

using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
namespace sarawebpart.Layouts.sarawebpart
{
    public partial class saraweb : LayoutsPageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BindData();
        }
        public void BindData()
        {
            using (SPSite osite = new SPSite(SPContext.Current.Site.Url))
            {
                using (SPWeb oweb = osite.OpenWeb())
                {
                    SPList EmpList = oweb.Lists["Employee"];
                    SPListItemCollection oitemcol = EmpList.Items;
                    Grid1.DataSource = oitemcol.GetDataTable();
                    Grid1.DataBind();
                }
            }
        }

    }
}

c#(aspx)

<asp:GridView ID="Grid1" runat="server" AutoGenerateColumns="false">
    <Columns>
                <asp:BoundField DataField="Title" HeaderText="First Name" />
                 <asp:BoundField DataField="LastName" HeaderText="Last Name" />
                  <asp:BoundField DataField="Salary" HeaderText="Salary" />
                </Columns>
                <HeaderStyle BackColor="Orange" ForeColor="White" />

    </asp:GridView>