Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Friday, August 10, 2012

Insertion into SharePoint List Using GridView

Ascx
<asp:GridView ID="dgvInsertRecord" runat="server" AutoGenerateColumns="False"
    CellPadding="4" ForeColor="#333333" GridLines="None"  ShowFooter="True"
    onrowcommand="dgvInsertRecord_RowCommand">
        <Columns>
            <asp:TemplateField>
            <HeaderTemplate>
            <table width="100%" cellpadding="0" cellspacing="0">
            <tr>
            <td width="25%">
            Fname
            </td>
             <td width="25%">
            City
            </td>
             <td width="50%">
           Telno
            </td>
            </tr>
            </table>
            </HeaderTemplate>
            <ItemTemplate >
            <table width="100%" cellpadding="0" cellspacing="0">
            <tr>
            <td align="center" width="25%">
            <%#Eval("Fname") %>
            </td>
              <td align="center" width="25%">
             <%#Eval("City") %>
            </td>
             <td align="center" width="50%">
            <%#Eval("Telno") %>
            </td>
            </tr>
            </table>
            </ItemTemplate>
            <FooterTemplate>
            <table  cellpadding="0" cellspacing="0">
            <tr>
            <td align="center" width="25%">
            <asp:TextBox ID="txtFname" runat="server"></asp:TextBox>
            </td>
            <td align="center" width="25%">
            <asp:TextBox ID="txtCity" runat="server"></asp:TextBox>
            </td>
            <td align="center" width="50%">
            <asp:TextBox ID="txtTelno" runat="server"></asp:TextBox>&nbsp;<asp:Button ID="btnSave" runat="server" Text="Save" CommandName="Insert" />
            </td>
            </tr>
            </table>
            </FooterTemplate>
            </asp:TemplateField>
        </Columns>
            <RowStyle BackColor="#E3EAEB" />
            <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#7C6F57" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>

Ascx.Cs
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using System.Security;

namespace GridInsert.VisualWebPart1
{
    public partial class VisualWebPart1UserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }

        public void BindData()
        {
            SPWeb currentWeb = SPContext.Current.Web;
            SPList lst = currentWeb.Lists["Contacts"];
            SPListItemCollection myColl = lst.Items;
            dgvInsertRecord.DataSource = myColl.GetDataTable();
            dgvInsertRecord.DataBind();
        }

        protected void dgvInsertRecord_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Insert")
            {
                SPWeb currentWeb = SPContext.Current.Web;
                SPList lst = currentWeb.Lists["Contacts"];
                SPListItemCollection myColl = lst.Items;
                TextBox txtFname1 = (TextBox)dgvInsertRecord.FooterRow.FindControl("txtFname");
                TextBox txtCity1 = (TextBox)dgvInsertRecord.FooterRow.FindControl("txtCity");
                TextBox txtTelno1 = (TextBox)dgvInsertRecord.FooterRow.FindControl("txtTelno");
                SPListItem item = myColl.Add();
                item["Fname"] = txtFname1.Text;
                item["City"] = txtCity1.Text;
                item["Telno"] = txtTelno1.Text;
                item.Update();
                txtFname1.Text = "";
                txtCity1.Text = "";
                txtTelno1.Text = "";
                BindData();
            }
        }
    }
}



Thursday, August 09, 2012

Binding Data from Document Library to SpGridView using Client Object Model without Dataset


 
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="VisualWebPart1UserControl.ascx.cs" Inherits="COMGridDocuments.VisualWebPart1.VisualWebPart1UserControl" %>

<SharePoint:SPGridView runat="server" ID="sgvDocuments" AutoGenerateColumns="false">
<Columns>
<asp:HyperLinkField HeaderText="Document Name" DataTextField="LinkFilename" DataNavigateUrlFields="EncodedAbsUrl" DataNavigateUrlFormatString="{0}" Target="_blank" />
</Columns>
</SharePoint:SPGridView>

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Linq;
using Microsoft.SharePoint.Client;
using System.Collections.Generic;
using Microsoft.SharePoint;

namespace COMGridDocuments.VisualWebPart1
{
    public partial class VisualWebPart1UserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            sgvDocuments.DataSource = getData();
            sgvDocuments.DataBind();
        }

        public class DocumentsData
        {
            public string LinkFilename { get; set; }
            public string EncodedAbsUrl { get; set; }
        }

        public List<DocumentsData> getData()
        {
            List<DocumentsData> MyDocumentsData = new List<DocumentsData>();
            using (ClientContext clientContext = new ClientContext(SPContext.Current.Web.Url))
            {
                List list = clientContext.Web.Lists.GetByTitle("NewDocuments");
                var camlQuery = new CamlQuery { ViewXml = "<View Scope='Recursive'><Query><OrderBy><FieldRef Name='ID' Ascending='False' /></OrderBy></Query><ViewFields><FieldRef Name='LinkFilename' /><FieldRef Name='EncodedAbsUrl' /></ViewFields></View>" };
                Microsoft.SharePoint.Client.ListItemCollection myColl = list.GetItems(camlQuery);
                clientContext.Load(myColl,li => li.Include(pi => pi["LinkFilename"], pi => pi["EncodedAbsUrl"]));
                clientContext.ExecuteQuery();
                foreach (Microsoft.SharePoint.Client.ListItem item in myColl)
                {
                    MyDocumentsData.Add(new DocumentsData()
                    {
                        LinkFilename = item["LinkFilename"].ToString(),
                        EncodedAbsUrl = item["EncodedAbsUrl"].ToString()
                    });
                }
            }
            return MyDocumentsData;


        }
    }
}




Wednesday, August 08, 2012

How to Inherit Columns from Existing List to Content Type in SharePoint 2007

  1. First Create a Content Type
  2. Now Go to the List you wnat to use and add the content type.
  3. Now Go to the AllItems Page of the list & click on List Settings.
  4. Now click on the custom content type you have added to the list.
  5. In that page Select List Columns in the DropDown list & Select the list columns you want & press add. Now click ok

Wednesday, July 25, 2012

How to fetch the details of the user if he is available within any one of the SharePoint Groups

Ascx
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="VisualWebPart1UserControl.ascx.cs" Inherits="SPUserFromGRoup.VisualWebPart1.VisualWebPart1UserControl" %>
<table cellpadding="0" cellspacing="0">
<tr><td>Enter UserName</td><td><SharePoint:PeopleEditor ID="pplUserName" runat="server" MultiSelect="false" /></td></tr>
<tr><td colspan="2" align="center"><asp:Button ID="btnPeopleSearch" runat="server"
        Text="Search User" onclick="btnPeopleSearch_Click" /></td></tr>
<tr>
<td colspan="2">
<asp:GridView runat="server" ID="dgvSearchUser"></asp:GridView>
</td>
</tr>
<tr><td colspan="2"><asp:label id="lblErrorMessage" runat="server"></asp:label> </td></tr>
</table>


Ascx.cs
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using System.Security;

namespace SPUserFromGRoup.VisualWebPart1
{
    public partial class VisualWebPart1UserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void btnPeopleSearch_Click(object sender, EventArgs e)
        {
            try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    SPWeb currentWeb = SPContext.Current.Web;
                    SPList lst = currentWeb.Lists["User Information List"];
                    SPQuery sQuery = new SPQuery();
                    sQuery.Query = "<OrderBy><FieldRef Name='ID' Ascending='False' /></OrderBy><Where><And><Eq><FieldRef Name='Name' /><Value Type='Text'>" + pplUserName.Accounts[0].ToString() +"</Value></Eq><Eq><FieldRef Name='ContentType' /><Value Type='Choice'>Person</Value></Eq></And></Where>";
                    sQuery.ViewFields = "<FieldRef Name='Title' /><FieldRef Name='Name' /><FieldRef Name='EMail' /><FieldRef Name='Department' /><FieldRef Name='FirstName' /><FieldRef Name='LastName' />";
                    sQuery.ViewFieldsOnly = true;
                    SPListItemCollection myColl = lst.GetItems(sQuery);
                    if (myColl.Count > 0)
                    {
                        dgvSearchUser.DataSource = myColl.GetDataTable();
                        dgvSearchUser.DataBind();
                    }
                });
            }
            catch (Exception ex)
            {

                lblErrorMessage.Text = ex.ToString();

            }


        }
    }
}



Imp Rss Feeds SharePoint Blogs

http://kancharla-sharepoint.blogspot.in/feeds/posts/default

http://sharepoint2010tutorialnew.blogspot.in/feeds/posts/default

http://moresharepoints.blogspot.com/feeds/posts/default

http://moresharepoints.blogspot.com/feeds/posts/default

http://feeds.feedburner.com/tobiaszimmergren

http://ranaictiu-technicalblog.blogspot.in/feeds/posts/default

http://sajiviswam.wordpress.com/feed/

http://feeds.feedburner.com/chrisobrien

You can add these urls to your mail box.

Friday, July 20, 2012

SharePoint 2013 People Picker Control not User Friendly.

In SharePoint 2013 People Picker Control there is no option to search the user from Active Directory. It will be a problem if we don't know the exact username.

Wednesday, July 18, 2012

Multiple Sites Concept in SharePoint 2013

In SharePoint 2013 while creating a SiteCollection we have will have 2 dropdowns 2010 & 2013. If You select 2010 I am able to create a SharePoint 2010 site & There is an option to Upgrade to SharePoint 2013 site.

Any How if you select directly 2013 you can directly create a site in SharePoint 2013.

Tuesday, July 17, 2012

Capabilities and features in SharePoint 2013

Branding

The design features in SharePoint 2013 offer an improved process for designing a public-facing internet site or an internal-facing intranet site with pixel-perfect branding. If you are a professional web designer who knows HTML, CSS, and JavaScript, you already have the skills necessary to design a SharePoint site. The new features in a publishing site minimize the amount of SharePoint knowledge that is required to successfully design and brand a SharePoint site.

Business Connectivity Services

Business Connectivity Services offers improvements to the way that SharePoint 2013 and Office 2013 clients can access data that is stored outside of SharePoint. These improvements include support for apps in SharePoint, external list improvements to provide functional parity with other SharePoint lists, and support for OData Business Data Connectivity (BDC) connections. Visual Studio 2010 can connect to an OData endpoint through business Connectivity Services to automatically generate a BDC model for OData data sources. There is a SharePoint 2013 event listener and subscriber to receive notifications from external systems when data changes.

Business intelligence

SharePoint Server 2013 business intelligence applications and tools let you organize your vision of organizational goals, processes, and performance requirements. Create powerful data mash-ups using PowerPivot, with the ability to process billions of rows, create data models and facilitate sharing and collaboration with Excel Services. Power View provides intuitive ad-hoc reporting. With PerformancePoint Services and Dashboard Designer, along with Visio Services, create sophisticated dashboards capable of integrating reports and metrics from multiple data sources that are customizable for your audience.

eDiscovery

The eDiscovery functionality in SharePoint 2013 provides improved ways to help protect your business. These improvements include the ability to perform eDiscovery queries across multiple SharePoint farms and Exchange servers, to preserve and export discovered content, to preserve content in-place from Exchange mailboxes and SharePoint sites while allowing users to continue working with content, and support for search and export from file shares.

Identity management

Authentication enhancements in SharePoint 2013 ease the process of using claims-based authentication. Additionally, support for server-to-server authentication and app authentication by utilizing and extending the Open Authorization 2.0 (OAuth 2.0) web authorization protocol enables new scenarios and functionality for Exchange Server 2013, Lync Server 2013, and apps in the SharePoint Store or App Catalog.

Mobile devices

SharePoint Server 2013 offers new, optimized viewing experiences across different mobile platforms. Additionally, there are several features that are available to help improve both worker productivity and usability on the device.

Records management and compliance

The records management and compliance features in SharePoint 2013 provide improved ways to help you protect your business. The records archive and in-place record retention from earlier versions of SharePoint Server are still supported, and SharePoint 2013 introduces retention policies that can be applied at the site level.
Enterprise search in SharePoint Server 2013 includes many of the capabilities of SharePoint Server 2010 and provides numerous improvements, such as in query processing and targeting of search results. Administrators can configure search to enable users to find relevant information more quickly and easily than ever before.

Social computing

The social computing and collaboration features in SharePoint 2013 offer an improved administration and user experience, in addition to new functionality for enterprise users to share and collaborate with others in their organization. The introduction of Community Sites offers a forum experience to categorize discussions around subject areas, and to connect users who have knowledge or seek knowledge about subject areas. Additionally, the new Community Portal enables a search-driven result page of communities for users to discover and explore from a link on their My Sites. Improvements to My Sites offer a more intuitive workflow for users to develop their personal profiles, store content, and keep up-to-date with activities of interest through the use of the new microblog and feeds experience.

Upgrade

The upgrade features in SharePoint 2013 offer several improvements, such as upgrade for service applications and site collections, and a site health checker. The database-attach method is the only supported way to upgrade databases to a new environment that is based on SharePoint 2013. In-place upgrade is not supported. Additionally, the upgrade process now separates the upgrade of software and databases from the upgrade of the SharePoint sites.

Web content management

The web content management improvements in SharePoint 2013 simplify how you design publishing sites, and enhance the authoring and publishing processes of your organization. It also contains new features that use enterprise search to surface dynamic web content on publishing sites.

What is SharePoint 2013?

SharePoint Server 2013 provides a comprehensive solution for connected information work that enables people to transform the way they work while preserving the benefits of structured processes, compliance, and existing IT investments.
SharePoint Server 2013 has been optimized for the way people work, providing people with a familiar, consistent view of information, collaboration, and process, and IT with a comprehensive, easily-managed and integrated platform to meet the needs of the business.