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, 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();
            }
        }
    }
}

Monday, April 01, 2013

Windows7 And Windows Server 2008 R2 Not getting Booted in Normal Mode.

This will happen after the windows update is performed. To resolve this please follow the below steps.
  1. Open your windows 7/Windows Server 2008 R2 in Safe Mode.
  2. Now click on Control Panel.
  3. In Control Panel click on Programs.
  4. Now you will find Programs & Features.
  5. Now you will find all the programs installed in your machine.
  6. Filter the softwares based on Installed on date.
  7. Now you see the software with Today date.
  8. Select respective software and uninstall it.
Note:-
I think the name of the s/w would be Intel HD Accelerated Graphics Driver.

Binding items From SharePoint List to Combo Box using SilverLight Client Object Model

Note:-
If you want to bind both Value and Text for Combo Box Please select SilverLight Version 4 in order to make selected value property of Combo Box to work. In SilverLight Version3 you will not find the property of selected value for Combo Box.
Ascx
<UserControl x:Class="SilverlightApplication1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">
        <ComboBox Height="37" HorizontalAlignment="Left" Margin="10,10,0,0" Name="ddlBindData" VerticalAlignment="Top" Width="247" DisplayMemberPath="Title" SelectedValuePath="ID" SelectedValue="{Binding Path=ID, Mode=TwoWay}"  />
    </Grid>
</UserControl>


Ascx.Cs
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;
using Microsoft.SharePoint.Client;

namespace SilverlightApplication1
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            ddlBindData.SelectionChanged += new SelectionChangedEventHandler(ddlBindData_SelectionChanged);
            getData();
        }

        void ddlBindData_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            MessageBox.Show(ddlBindData.SelectedValue.ToString());
        }

        public class NewThoughts
        {
            public int ID{get;set;}
            public string Title{get;set;}
        }
        private IEnumerable<ListItem> myColl = null;
        public void getData()
        {
            try
            {
                ClientContext context = ClientContext.Current;
                Web objWeb = context.Web;
                List lstNewThoughts = objWeb.Lists.GetByTitle("New Ideas");
                CamlQuery strQuery = new CamlQuery();
                strQuery.ViewXml = "<View><Query><OrderBy><FieldRef Name='Title' /></OrderBy></Query></View>";
                var items = lstNewThoughts.GetItems(strQuery);
                context.Load(lstNewThoughts);
                myColl = context.LoadQuery(items.Include(l => l["Title"], l=>l.Id));
                context.ExecuteQueryAsync(OnListItemsLoadSucceeded, OnFailure);
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.ToString());
            }
        }
        private delegate void UpdateUIMethod();
        private void OnListItemsLoadSucceeded(object sender, ClientRequestSucceededEventArgs e)
        {
            UpdateUIMethod updateUI = LoadListItems;
            this.Dispatcher.BeginInvoke(updateUI);
        }
        private void OnFailure(object sender, ClientRequestFailedEventArgs e)
        {
            MessageBox.Show("Request Failed: " + e.Message + ", Stack Trace:" + e.StackTrace);
        }
        private void LoadListItems()
        {
            ddlBindData.Visibility = System.Windows.Visibility.Visible;
            List<NewThoughts> lItems = new List<NewThoughts>();
            foreach (ListItem item in myColl.ToList())
                lItems.Add(new NewThoughts
                {
                    Title = item["Title"].ToString(),
                    ID=item.Id,
                });
            ddlBindData.ItemsSource = lItems;
        }
    }

}