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.

Tuesday, June 04, 2013

SharePoint 2007 List Edit in Datasheet not working in IE10

When i open Edit in Datasheet view with IE 10 then i was not able to see the excel type output. To make this functionality work i clicked on F12 to open IE toolbar  and went to Browsermode menu and selected IE8 compatibility view. Then i am able to open edit in datasheet view option.

Thursday, May 30, 2013

Tuesday, May 14, 2013

Remodeled Code: Progress Bar in GridView using SharePoint Tasks List



 The old post is available in this location:- Old Code for Progress Bar in GridView

Notes:-
  1. For Percentcomplete column keep 0 as default value.
  2. Specify Minimum value as 0 and Maximum value as 100.
  3. Create one caluclated column in Tasks List with name ConvertPC.
  4. Now in the column do the settings3and code as shown in the below figure.

  1. This is used to convert double value into Percentage.
  2. Now Press ok and take the TemplateField in the GridView and do the changes as shown in the ascx file.

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="TestPBarUserControl.ascx.cs" Inherits="TestPBar.TestPBar.TestPBarUserControl" %>
<asp:GridView ID="dgvProgressBarSample" runat="server" CellPadding="4"
    EnableModelValidation="True" ForeColor="#333333" GridLines="Both" AutoGenerateColumns="false" Width="100%">
    <AlternatingRowStyle BackColor="White" />
    <EditRowStyle BackColor="#7C6F57" />
    <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
    <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
    <RowStyle BackColor="#E3EAEB" />
    <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
    <Columns>
    <asp:BoundField HeaderText="Title" DataField="Title" />
    <asp:TemplateField HeaderText="% Complete">
    <ItemTemplate><div><table width="<%# Eval("ConvertPC") %>%"  bgcolor="yellow"><tr><td><strong><%# Eval("ConvertPC") %>%</strong></td></tr></table></div></ItemTemplate>
    <AlternatingItemTemplate><div><table width="<%# Eval("ConvertPC") %>%"  bgcolor="yellow"><tr><td><strong><%# Eval("ConvertPC") %>%</strong></td></tr></table></div></AlternatingItemTemplate>
    </asp:TemplateField>
    </Columns>
</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 TestPBar.TestPBar
{
    public partial class TestPBarUserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            SPWeb currentMeb = SPContext.Current.Web;
            SPList lst = currentMeb.Lists["Tasks"];
            SPQuery sQuery = new SPQuery();
            sQuery.Query = "";
            SPListItemCollection myColl = lst.GetItems(sQuery);
            if (myColl.Count > 0)
            {
                dgvProgressBarSample.DataSource = myColl.GetDataTable();
                dgvProgressBarSample.DataBind();
            }

        }
    }
}

STSADM vs PowerShell


Using PowerShell we can do more program oriented things like retrieving lists in the site, retrieving sub web details etc., where as we cannot do these things with STSADM command. We can do all things with PowerShell what we can do with STSADM command.

Friday, May 03, 2013

JQuery Plugin 1.9.1 not supporting SPServices

I am unable to pull the data from SharePoint List when i use JQuery plugin 1.9.1. When i used JQuery 1.8.3 plugin then i am able to retrieve data successfully.

Friday, April 12, 2013

Problem with JQuery Show() Method when an html control is in Show() state.

I have two divs Div1 and Div2.

I opened Div1 and Div2.

I div1 function i need to close Div2. Suppose if i open Div1 and Div2 both then div2 is also in show() state. If div is in show state and if you try to perform show() on Div2 then you will get the error "object doesnt support this property or method". To avoid this you have to check whether the object div2 is in hide() mode or not.

Example:-
     if($('#div2').hide())
     {
            //Perform show Operation.
           $('#div2').show();
     }


Thursday, April 04, 2013

Insert User into People Picker Column who is not part of SiteCollection



SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    SPListItemCollection myColl = SPContext.Current.Web.Lists["Test People Editor"].Items;
                    SPListItem item = myColl.Add();
                    SPUser user = SPContext.Current.Web.EnsureUser(pplUserName.Accounts[0].ToString());
                    string strUser = user.ID.ToString();
                    SPContext.Current.Web.Update();
                    item["UserName"] = strUser;
                    item.Update();
                });

Tuesday, April 02, 2013

Showing Image Loader while performing Paging in GridView

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="ImageLoadingGridViewUserControl.ascx.cs" Inherits="ImageLoadingGridView.ImageLoadingGridView.ImageLoadingGridViewUserControl" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Label ID="lblMessage" runat="server"></asp:Label>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<img alt="progress" src="/UserPages/Loading_Images/loading_1.gif" />         
</ProgressTemplate>
</asp:UpdateProgress>
<asp:GridView ID="dgvMovingImage" runat="server" AutoGenerateColumns="False"
        Width="100%" AllowPaging="True" CellPadding="4" EnableModelValidation="True"
        ForeColor="#333333"
        onpageindexchanging="dgvMobingImage_PageIndexChanging" PageSize="20">
    <AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField HeaderText="ItemID" DataField="ID" />
<asp:BoundField HeaderText="Title" DataField="Title" />
</Columns>
    <EditRowStyle BackColor="#2461BF" />
    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <PagerSettings Mode="NextPrevious" NextPageText="Next"
        PreviousPageText="Previous" />
    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
    <RowStyle BackColor="#EFF3FB" />
    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
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 ImageLoadingGridView.ImageLoadingGridView
{
    public partial class ImageLoadingGridViewUserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                getData();
            }
        }

        protected void dgvMobingImage_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            try
            {
                System.Threading.Thread.Sleep(3000);
                dgvMovingImage.PageIndex = e.NewPageIndex;
                getData();
            }
            catch (Exception Ex)
            {
                lblMessage.Text = Ex.ToString();
            }
        }

        public void getData()
        {
            try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    SPQuery strQuery = new SPQuery();
                    strQuery.Query = "";
                    SPListItemCollection myColl = SPContext.Current.Web.Lists["Moving Image Test"].GetItems(strQuery);
                    if (myColl.Count > 0)
                    {
                        dgvMovingImage.DataSource = myColl.GetDataTable();
                        dgvMovingImage.DataBind();
                    }
                });
            }
            catch (Exception Ex)
            {
                lblMessage.Text = Ex.ToString();
            }
        }
    }
}