Hello All, We are going to start new batch from next week. message/call or mail us for more details.

27 July 2012

SharePoint Roles and Responsibilities

In this article I am describing the roles and responsibilities of SharePoint. After reading my article SharePoint Development Methodology, many people have asked me what are the different roles and responsibilities in SharePoint projects. Each one has a different opinion but here I am mentioning my view points.

Typically in a SharePoint project the main roles are:
  • SharePoint Administrator
  • SharePoint Developer
  • SharePoint Designer
  • SharePoint Architect
SharePoint Administrator
The role of SharePoint administrator includes setting up the SharePoint infrastructure with servers and services; SharePoint 2007/2010, Exchange Server, Active Directory, Windows 2003 and 2008 Servers, SQL Server 2005/2008, IIS 6.0 and 7.0, network infrastructure, ISA server, etc. He is responsible for maintaining and optimizing the SharePoint farm.
A SharePoint administrator requires knowledge of both SQL Server and Windows Server. Since SharePoint stores all of its data in SQL Server databases, DBA knowledge is critical. However, the Windows Server knowledge required to build and maintain a SharePoint farm is considerable. The administrator role is often split between two people who work closely together: a Windows Server administrator and a SQL Server DBA.The DBA skills required are the standard set required for any SQL Server but the features of Windows Server that a SharePoint Administrator needs to have some knowledge of include:
  • Good knowledge in IIS and the architecture of it
  • Windows Server Manager
  • Active Directory (LDAP,ADLDS,ADAM etc)
  • DNS and SMTP
  • Network Load Balancing (NLB)
  • Firewall (Hardware and software NLB)
  • Event Viewer and Performance Monitor
  • PowerShell scripting will be added advantage if looking in SharePoint 2010
But I suggest some knowledge of SharePoint development experience will add extra benefits to this role.

SharePoint Developer

The main role of a developer is developing custom web parts and component for SharePoint. They should have experience in Asp.net, C#.net, web parts, master pages, Ajax developer, detailed knowledge of the SharePoint 2007 object model / 2010 client object model, JavaScript experience etc. A SharePoint developer should be well versed on .NET frame work and windows workflow foundations (WFF). The Developer should have a solid understanding of C# and or VB.net and a solid understanding of the SharePoint API as a whole. Building workflows from a completely custom Visual studio direction as well as custom coding SQL and SQL server manipulation and maintenance also required so some knowledge in DB side also needed.  XML/XSLT knowledge will also provide some extra value in development. Since most things in SharePoint are xml based or can be converted and fed as xml/xsl, these are just another set of skills are another way that the developer can increase their value. A solid understanding of IIS and editing web config files are needed for a developer.
However, the main thing is to understand the out-of-the-box functionality and SharePoint web services well enough so that you don't program something SharePoint has Out of the box. SharePoint development involves tuning functionality that SharePoint has out of the box. So we should explain how to achieve project requirements with the least amount of programming.

SharePoint Designer

There are some wiles that a SharePoint Designer is really needed for the SharePoint project. But as per my experience it is good to have a Designer in your team so the developers can focus on programming no need to waste their time on customization. Designers are responsible for all the "non-programming" customization of the SharePoint solution. Good understanding of SharePoint and the different out of the box web parts and their functionality are needed for this role. Experience with html, style sheet, caml, xml, xslt, java script, SharePoint Designer 2007/2010 and InfoPath 2007/2010 are the main areas they have to focus.

SharePoint Architect

SharePoint Architect needs to have a thorough understanding of SharePoint (admin, developing, functions) including when and how new components/web parts should be developed. Also Microsoft Technologies in general, especially .NET 3.5, C#, Exchange, Active Directory, Office 2007/2010, IIS and infrastructure in general. Pivotal specialized role is of SharePoint architect. This is the person who can:
1.       Collect, transform, validate and map functional and non-functional requirements
2.       Plan and architect infrastructure integration
3.       Define solution
4.       Map MOST of solution requirements to existing configurable features of SharePoint
5.       Architect and POC custom code as needed.

The Architect also needs to set up the projects environments. In some cases this can be a full blown Development, Staging and Production environment. If that is the case it's very important to have all the environments match as close as possible if not be exact. The Architect also needs to understand fail over's, clustering and load balancing, for large farms. A SharePoint Architect also needs a solid understanding of alternate access mapping in MOSS, host headers, DNS entries, Kerberos configuration and multiple forms of authentication (forms auth, ntml etc).  

13 July 2012

GridView - Add Edit Update Delete and Paging the AJAX way

GridView - Add Edit Update Delete and Paging the AJAX way You might have seen many articles explaining ASP.Net GridView Add (Insert), Edit, Update and Delete functionality, but this is different and how I’ll explain as we progress. My main objective in this article is to keep it simple and cover multiple aspects in one article.


Basically I have tried to make the normal Add (Insert), Edit, Update and delete functions in ASP.Net GridView simple and also combining the powers of ASP.Net AJAX with that of JQuery to give an elegant and charming user experience.




Database and Connection String         
For this article as usual I have used my favorite NorthWind database which you can get by clicking on the link below.

Database and Connection String   
<connectionStrings>
      <add name="constar" connectionString="Data Source=Lenovo-pc;
      database=Pankaj;Integrated Security=true"/>
</connectionStrings>

The GridView
Below is the markup of the ASP.Net GridView control that I’ll be using to demonstrate the various features explained in this article.
<div id = "dvGrid" style ="padding:10px;width:550px">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server"  Width = "550px"
AutoGenerateColumns = "false" Font-Names = "Arial"
Font-Size = "11pt" AlternatingRowStyle-BackColor = "#C2D69B" 
HeaderStyle-BackColor = "green" AllowPaging ="true"  ShowFooter = "true" 
OnPageIndexChanging = "OnPaging" onrowediting="EditCustomer"
onrowupdating="UpdateCustomer"  onrowcancelingedit="CancelEdit"
PageSize = "10" >
<Columns>
<asp:TemplateField ItemStyle-Width = "30px"  HeaderText = "CustomerID">
    <ItemTemplate>
        <asp:Label ID="lblCustomerID" runat="server"
        Text='<%# Eval("CustomerID")%>'></asp:Label>
    </ItemTemplate>
    <FooterTemplate>
        <asp:TextBox ID="txtCustomerID" Width = "40px"
            MaxLength = "5" runat="server"></asp:TextBox>
    </FooterTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width = "100px"  HeaderText = "Name">
    <ItemTemplate>
        <asp:Label ID="lblContactName" runat="server"
                Text='<%# Eval("ContactName")%>'></asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
        <asp:TextBox ID="txtContactName" runat="server"
            Text='<%# Eval("ContactName")%>'></asp:TextBox>
    </EditItemTemplate> 
    <FooterTemplate>
        <asp:TextBox ID="txtContactName" runat="server"></asp:TextBox>
    </FooterTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width = "150px"  HeaderText = "Company">
    <ItemTemplate>
        <asp:Label ID="lblCompany" runat="server"
            Text='<%# Eval("CompanyName")%>'></asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
        <asp:TextBox ID="txtCompany" runat="server"
            Text='<%# Eval("CompanyName")%>'></asp:TextBox>
    </EditItemTemplate> 
    <FooterTemplate>
        <asp:TextBox ID="txtCompany" runat="server"></asp:TextBox>
    </FooterTemplate>
</asp:TemplateField>
<asp:TemplateField>
    <ItemTemplate>
        <asp:LinkButton ID="lnkRemove" runat="server"
            CommandArgument = '<%# Eval("CustomerID")%>'
         OnClientClick = "return confirm('Do you want to delete?')"
        Text = "Delete" OnClick = "DeleteCustomer"></asp:LinkButton>
    </ItemTemplate>
    <FooterTemplate>
        <asp:Button ID="btnAdd" runat="server" Text="Add"
            OnClick = "AddNewCustomer" />
    </FooterTemplate>
</asp:TemplateField>
<asp:CommandField  ShowEditButton="True" />
</Columns>
<AlternatingRowStyle BackColor="#C2D69B"  />
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID = "GridView1" />
</Triggers>
</asp:UpdatePanel>
</div>

The GridView has 3 data columns
1. Customer ID
2. Contact Name
3. Company Name
I have added a LinkButton in 4th column which will act as custom column for delete functionality. The reason to use a custom button is to provide the JavaScript confirmation box to the user when he clicks Delete. For Edit and Update I have added a command field which will act as the 5th column.
There’s also a Footer Row with 3 TextBoxes which will be used to add new records to the database and an Add button which will be used to add the records.
I have enabled pagination and finally wrapped the complete Grid in update panel and the update panel in a div dvGrid and the reason to that I’ll explain later in the article

Binding the GridView
Below is the code to bind the GridView in the page load event of the page
private String strConnString = ConfigurationManager.ConnectionStrings["constar"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        BindData();
    }
}
private void BindData()
{
    string strQuery = "select CustomerID,ContactName,CompanyName" +
                       " from customers";
    SqlCommand cmd = new SqlCommand(strQuery);
    GridView1.DataSource = GetData(cmd);
    GridView1.DataBind();
}

Get your GetData function here 

  private DataTable GetData(SqlCommand cmd)
    {
        DataTable dt = new DataTable();
        SqlConnection con = new SqlConnection(strConnString);
        SqlDataAdapter sda = new SqlDataAdapter();
        cmd.CommandType = CommandType.Text;
        cmd.Connection = con;
        con.Open();
        sda.SelectCommand = cmd;
        sda.Fill(dt);
        return dt;
    }

Adding new record
As discussed above I have placed 3 textboxes and a button in the Footer Row of the ASP.Net GridView control in order to add new record to the database. On the onclick event if the button the records are inserted into the SQL Server Database and the GridView is updated
protected void AddNewCustomer(object sender, EventArgs e)
{
  string CustomerID=((TextBox)GridView1.FooterRow.FindControl("txtCustomerID")).Text;
  string Name = ((TextBox)GridView1.FooterRow.FindControl("txtContactName")).Text;
  string Company = ((TextBox)GridView1.FooterRow.FindControl("txtCompany")).Text;
  SqlConnection con = new SqlConnection(strConnString);
  SqlCommand cmd = new SqlCommand();
  cmd.CommandType = CommandType.Text;
  cmd.CommandText = "insert into customers(CustomerID, ContactName, CompanyName) " +
  "values(@CustomerID, @ContactName, @CompanyName);" +
  "select CustomerID,ContactName,CompanyName from customers";
  cmd.Parameters.Add("@CustomerID"SqlDbType.VarChar).Value = CustomerID;
  cmd.Parameters.Add("@ContactName"SqlDbType.VarChar).Value = Name;
  cmd.Parameters.Add("@CompanyName"SqlDbType.VarChar).Value = Company;
  GridView1.DataSource = GetData(cmd);
  GridView1.DataBind();
}
Note:- You will notice I am firing two queries one to insert the data and second to select the updated data and then rebind the GridView. The figure below displays how new records are added.

Edit and Update existing records
As described above I have used command field in order to provide the Edit functionality. Below is the code snippet which is used to edit and update the records

protected void EditCustomer(object sender, GridViewEditEventArgs e)
{
    GridView1.EditIndex = e.NewEditIndex;
    BindData();
}
protected void CancelEdit(object sender, GridViewCancelEditEventArgs e)
{
    GridView1.EditIndex = -1;
    BindData();
}
protected void UpdateCustomer(object sender, GridViewUpdateEventArgs e)
{
    string CustomerID = ((Label)GridView1.Rows[e.RowIndex]
                        .FindControl("lblCustomerID")).Text;
    string Name = ((TextBox)GridView1.Rows[e.RowIndex]
                        .FindControl("txtContactName")).Text;
    string Company = ((TextBox)GridView1.Rows[e.RowIndex]
                        .FindControl("txtCompany")).Text;
    SqlConnection con = new SqlConnection(strConnString);
    SqlCommand cmd = new SqlCommand();
    cmd.CommandType = CommandType.Text;
    cmd.CommandText = "update customers set ContactName=@ContactName," +
     "CompanyName=@CompanyName where CustomerID=@CustomerID;" +
     "select CustomerID,ContactName,CompanyName from customers";
    cmd.Parameters.Add("@CustomerID"SqlDbType.VarChar).Value = CustomerID;
    cmd.Parameters.Add("@ContactName"SqlDbType.VarChar).Value = Name;
    cmd.Parameters.Add("@CompanyName"SqlDbType.VarChar).Value = Company;
    GridView1.EditIndex = -1;
    GridView1.DataSource = GetData(cmd);
    GridView1.DataBind();
}

You can view above I am simply getting the data from the textboxes in the Footer Row and then firing an update query along with the select query so that the ASP.Net GridView control is also updated.

Deleting existing record with Confirmation
As said above I am using custom delete button instead of ASP.Net GridView delete command field and the main reason for that is to add a confirmation
protected void DeleteCustomer(object sender, EventArgs e)
{
    LinkButton lnkRemove = (LinkButton)sender;
    SqlConnection con = new SqlConnection(strConnString);
    SqlCommand cmd = new SqlCommand();
    cmd.CommandType = CommandType.Text;
    cmd.CommandText = "delete from  customers where " +
    "CustomerID=@CustomerID;" +
     "select CustomerID,ContactName,CompanyName from customers";
    cmd.Parameters.Add("@CustomerID"SqlDbType.VarChar).Value
        = lnkRemove.CommandArgument;
    GridView1.DataSource = GetData(cmd);
    GridView1.DataBind();
}

Based on the sender argument I am getting the reference of the LinkButton that is clicked and with the CommandArgument of the LinkButton I am getting the ID of the record to be deleted. After the delete query I am firing a select query and the rebinding the GridView

Pagination
For pagination I have added the OnPageIndexChanging event on which I am assigning the new page index to the ASP.Net GridView control and then rebinding the data.

protected void OnPaging(object sender, GridViewPageEventArgs e)
{
    BindData();
    GridView1.PageIndex = e.NewPageIndex;
    GridView1.DataBind();
}

ASP.Net AJAX and JQuery
As you have seen in the start I had added an Update Panel and a DIV along with ASP.Net GridView Control.
Basically the Update Panel will give the asynchronous calls thus not reloading the complete page and the JQuery will block the UI until the update panel is refreshed completely. But instead of blocking the complete page I am blocking only the contents of the DIV dvGrid. To achieve this I am using the JQuery BlockUI Plugin

<script type = "text/javascript" src = "scripts/jquery-1.3.2.min.js"></script>
<script type = "text/javascript" src = "scripts/jquery.blockUI.js"></script>
<script type = "text/javascript">
    function BlockUI(elementID) {
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_beginRequest(function() {
    $("#" + elementID).block({ message: '<table align = "center"><tr><td>' +
     '<img src="images/loadingAnim.gif"/></td></tr></table>',
     css: {},
     overlayCSS: {backgroundColor:'#000000',opacity: 0.6, border:'3px solid #63B2EB'
    }
    });
    });
    prm.add_endRequest(function() {
        $("#" + elementID).unblock();
    });
    }
    $(document).ready(function() {

            BlockUI("dvGrid");
            $.blockUI.defaults.css = {};           
    });
</script>

That’s all the scripting required and the following is achieved with the above scripts. It will block the Grid until the update panel finishes its work. Refer the figure below

GridView Blocked untill the Update Panel is refreshed using JQuery


That’s it. With this the article comes to an end, hope you liked it I’ll get back soon with a new one