stsadm Commands – SharePoint 2007


 
1.Create Solution File

makecab /f solutionName.ddf

2.Register your wsp file using stsadm.exe with SharePoint

stsadm.exe –o addsolution –filename C:\replacewithpathtofile\filename.wsp

3.Deploy Solution

stsadm.exe –o deploysolution –name filename.wsp –local –allowgacdeployment –allcontenturls

4.Activate Features

stsadm –o activatefeature–name <name and path of the folder containing the Feature.xml file>-url http://Server/Site/Subsite

5. STSADM Command for deactivating feature and retracting solution

stsadm -o deactivatefeature -id FEATUREGUID -url http:// -forcestsadm -o deactivatefeature -id FEATUREGUID -url http:// -forcestsadm -o execadmsvcjobsstsadm -o retractsolution -name WSPNAME.wsp -immediate -allcontenturlsstsadm -o execadmsvcjobs

6.STSADM Command for delete solution

stsadm -o deletesolution -name WSPNAME.wsp -overridestsadm -o execadmsvcjobs

7.STSADM Command for add solution and deploy solution

stsadm -o addsolution -filename WSPNAME.wspstsadm -o execadmsvcjobsstsadm -o deploysolution -name WSPNAME.wsp -url http:// -immediate -allowgacdeployment

8. STSADM Command for activating feature

stsadm -o execadmsvcjobsstsadm -o activatefeature -id FEATUREGUID -url http://stsadm -o activatefeature -id FEATUREGUID -url http://

9. Sample CMD File should look like this

@set PATH=C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN;%PATH%stsadm -o execadmsvcjobsstsadm -o activatefeature -id FEATUREGUID -url http://stsadm -o activatefeature -id FEATUREGUID -url http://

10. Import

stsadm.exe -o import -url http://localhost/sites/newsite -filename “C:\S28thApril2010\Demo.cab”

Posted in Sharepoint | Leave a comment

SPGridView and SPMenuField –Displaying data from sharepoint list

Part 1: Using SPGridview, adding menus, grouping and sortingSharePoint lists and libraries are great for storing almost everything, but what about if you need to display structured lists in SharePoint where the data is stored elsewhere?  If you use Office SharePoint Server (MOSS), one great feature for this purpose is the Business Data Catalogue.  However, if you only have Windows SharePoint Services (WSS), or need to dynamically construct data, chances are you’ll end up needing to write a Web Part.Web Parts give you some standard look and feel elements for free, like the ‘crome’ or border, plus an ability to add your own properties to the properties grid.  After that, you’re pretty much on your own.  Wouldn’t it be nice if you could display your own data in a sexy SharePoint list?SharePoint uses the Microsoft.SharePoint.WebControls.SPGridView control to display its own lists.  This class inherits from System.Web.UI.WebControls.GridView, so the development experience to bind data, adjust columns, perform sorting etc is similar.  The key difference is the control renders the grid in the SharePoint style – perfect.Create a Web PartAny blank Web Part will do – you could use the template provided by Visual Studio if you have the SharePoint SDK installed.  My web part started out life like this:using System;using System.Runtime.InteropServices;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Serialization;using System.Data;using Microsoft.SharePoint;using Microsoft.SharePoint.WebControls;using Microsoft.SharePoint.WebPartPages;namespace ListMenuSample{

public class ListMenuSample : System.Web.UI.WebControls.WebParts.WebPart

{

   private SPGridView oGrid;

   private TVData oDataset;

   private DataView oView;

            private void PopulateDataset()

{

   // TODO

          }

protected override void CreateChildControls()

{

  // TODO

}

  void oGrid_Sorting(object sender, GridViewSortEventArgs e)

{

  // TODO

}

}}

Create the data sourceIn this example, we’ll create and populate a dataset and use it for data binding.  I want a list to keep track of who presents my favourite BBC current affairs programmes, so I’ll design and populate a DataSet accordingly.My DataSet, TVProgrammeData has a single table, Presenters, comprising an int and two string columns:We’ll fill the DataTable from code, but obviously you’d want to pull this from somewhere, probably SQL, a filesystem, a web service or XML.  Pop this into the PopulateDataset() method.private void PopulateDataset()
{
    oDataset = new TVData();
    oDataset.Presenters.AddPresentersRow(1, “Jeremy Paxman”, “Newsnight”);
    oDataset.Presenters.AddPresentersRow(2, “Kirsty Wark”, “Newsnight”);
    oDataset.Presenters.AddPresentersRow(6, “Bill Turnbull”, “Breakfast”);
    oDataset.Presenters.AddPresentersRow(7, “Sian Williams”, “Breakfast”);
   // plus a few more entries
}
Render the GridOverriding CreateChildControls() is a good place to create your SPGridView and add it to the controls collection.  You’ll also need to bind up the columns and specify sorting.  To give us magical sorting abilities, we’ll bind to a DataView rather than directly back to the DataTable.  Pop this into CreateChildControls():protected override void CreateChildControls(){     PopulateDataset(); oView = new DataView(oDataset.Presenters);     oGrid = new SPGridView();     oGrid.DataSource = oView;     oGrid.AutoGenerateColumns = false;     oGrid.AllowSorting = true;    oGrid.Sorting += new GridViewSortEventHandler(oGrid_Sorting);    BoundField colName = new BoundField();    colName.DataField = “PresenterName”;    colName.HeaderText = “Presenter Name”;    colName.SortExpression = “PresenterName”;    oGrid.Columns.Add(colName);   // Add the menu control here   BoundField colProgramme = new BoundField();   colProgramme.DataField = “ProgrammeName”;   colProgramme.HeaderText = “Programme”;   colProgramme.SortExpression = “ProgrammeName”;  oGrid.Columns.Add(colProgramme);  Controls.Add(oGrid);  oGrid.DataBind();  base.CreateChildControls();}Notice we specify the SortExpression to use, which together with AllowSorting enables users to order the results by clicking the columns headers.  We need to perform the sort ourselves though, through the event handler; and we’ll need to keep track of the sort direction in ViewState so we can flip it next time the user clicks the same header.  I’m not sure my code is very elegant in this area, so leave a comment if you can think of a better way to do it in fewer lines of code.Add this event handler:void oGrid_Sorting(object sender, GridViewSortEventArgs e)
{
    string lastExpression = “”;
    if (ViewState[“SortExpression”] != null)
    lastExpression = ViewState[“SortExpression”].ToString();
    string lastDirection = “asc”;
    if (ViewState[“SortDirection”] != null)
    lastDirection = ViewState[“SortDirection”].ToString();
   string newDirection = “asc”;
   if (e.SortExpression == lastExpression)
   newDirection = (lastDirection == “asc”) ? “desc” : “asc”;
   ViewState[“SortExpression”] = e.SortExpression;
   ViewState[“SortDirection”] = newDirection;
   oView.Sort = e.SortExpression + ” ” + newDirection; oGrid.DataBind();
}
If you build and deploy this web part, you should get something like thisThat looks alright, and it will adapt correctly if you apply different style sheets, themes or a new master page.  But it’s still not a very rich interface.  How about if you wanted users to edit items, or get more detail.  Umm, better add a menu.Add a menuIt’s worth pointing out about now that the documentation around this area is still in production – so I’m coding with a slight emphasis on experimentation for some of the property values – I’ll point you to the official source when it’s revised.Anyway, SPMenuField is the class we need, and combines the roles of controlling the drop-down menu with the basic display work done by BoundField.  Let’s replace our boring colName column with a shiny menu that looks like this:/ /Replace the Name coloumn with a shiny menu
colName.Visible = false;
// You could remove colName completely
SPMenuField colMenu = new SPMenuField();
colMenu.HeaderText = “Presenter Name”;
colMenu.TextFields = “PresenterName”;
colMenu.MenuTemplateId = “PresenterListMenu”;
colMenu.NavigateUrlFields = “ID,PresenterName”;
colMenu.NavigateUrlFormat = “do.aspx?p={0}&q={1}”;
colMenu.TokenNameAndValueFields = “EDIT=ID,NAME=PresenterName”;
colMenu.SortExpression = “PresenterName”;
MenuTemplate presenterListMenu = new MenuTemplate();
presenterListMenu.ID = “PresenterListMenu”;
MenuItemTemplate biogMenu = new MenuItemTemplate( “Read Biography”, “/_layouts/images/EawfNewUser.gif”);
biogMenu.ClientOnClickNavigateUrl = “do.aspx?this=%EDIT%&that=%NAME%”;
//entry.ClientOnClickScript = “your javascript here”;
presenterListMenu.Controls.Add(biogMenu);
MenuItemTemplate broadcastMenu = new MenuItemTemplate( “Recent Broadcasts”, “/_layouts/images/ICWM.gif”); presenterListMenu.Controls.Add(broadcastMenu);
MenuSeparatorTemplate sepMenu = new MenuSeparatorTemplate();
presenterListMenu.Controls.Add(sepMenu);
MenuItemTemplate favMenu = new MenuItemTemplate( “Add to Favorites”, “/_layouts/images/addtofavorites.gif”); presenterListMenu.Controls.Add(favMenu);
this.Controls.Add(presenterListMenu);
oGrid.Columns.Add(colMenu);
Tip: You can have a poke around the standard icon collection and pick some suitable images from C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\IMAGESSPMenuField serves two purposes – it configures the hyperlink you follow if you click on the item directly and, optionally, links to a snazzy dropdown menu.Fortunately, there are a few ways to achieve with.  First we setup colMenu to pass in the required parameters when you click on the main item hyperlink:Here, NavigateUrlFields is a comma-separated list of data bound items we want to use in the URL.  Then we replace placeholders starting at {0} with the items in sequence.Next, we need to decide how to respond to clicks on the drop-down menu.  We have two options here – build a click URL similar to the one above, or use our own javascript.  We might have a third option to do a sexy postback to an event in the code behind, but I can’t decipher exactly how to use that yet – keep tuned.The URL way uses a modification in syntax but essentially the same principle as above.  This time we name the data fields we want and then consume them within % signs on the menu items:Let’s finish off for now by adding some grouping (and a few more presenters):oGrid.AllowGrouping = true;
oGrid.AllowGroupCollapse = true;
oGrid.GroupField = “ProgrammeName”;

oGrid.GroupDescriptionField = “ProgrammeName”;

oGrid.GroupFieldDisplayName = “Programme”;

Part 2: Extending your SPGridview with paging controlsExtending your codePop this code just above oGrid.DataBind():// Turn on paging and add event handler
oGrid.PageSize = 3;
oGrid.AllowPaging = true;
oGrid.PageIndexChanging += new GridViewPageEventHandler(oGrid_PageIndexChanging); oGrid.PagerTemplate = null;
// Must be called after Controls.Add(oGrid)
// Recreate current sort if needed
if (ViewState[“SortDirection”] != null && ViewState[“SortExpression”] != null)
{
   // We have an active sorting, so this need to be preserved
   oView.Sort = ViewState[“SortExpression”].ToString() + ” ” + ViewState[“SortDirection”].ToString();
}
and add the event handler:

void oGrid_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            oGrid.PageIndex = e.NewPageIndex;
            oGrid.DataBind();
        }
Posted in Sharepoint | Leave a comment

Create a Custom NewForm.aspx for a SharePoint List

 Steps1: Create New Custom SubmitForm.aspx page within Visiual studio and wirte down code withinSubmitForm.aspx.cs fileStep 2: Sign In by strong name key and Build ApplicationStep 3: Now Copy Dll in to Gac or respective bin folder of siteStep 4: Open Sharepoint site in sharepoint designerStep 5: Go to Lists folder and drag and drop SubmitForm.aspx and SubmitForm.aspx.cs file .Stpe6: Now Follow the steps to navigate Custom pagesSharePoint has a number of features when it comes to working with its built-in lists. One of these is that it automatically generates New (NewForm.aspx), Edit (EditForm.aspx) and Display (DispForm.aspx) for each list when it is created. While this is very useful, it is somewhat limited when you want to customize what is displayed, or how information is displayed on these pages.The answer to this problem is SharePoint Designer. In the following scenario, I will show you how to customize the NewForm.aspx page for a SharePoint List using SharePoint Designer.Your company wants to set up a Computer Equipment Request List to handle new requests that the employees have for the IT Department. So, you go and create the list in SharePoint. All is great until you realize that the majority of the information in the list is for internal IT use, and should not be presented to the end-user to fill out.All you really want the end-user to complete is the fields, Request Name, Description, and Requested Equipment.This is where SharePoint Designer comes to the rescue. By completing these steps, you will be customizing your own NewForm.aspx in no time.1. Open SharePoint Designer.2. Open the Site where your list resides.3. In the Folder List window select the Computer Equipment Request list. 4. Right-click on the NewForm.aspx and select New From Existing Page. This creates a new page based on the original NewForm page. It is a bad idea to modify the default NewForm page, for if you need to revert back to the original, which could prove to be a difficult task. In some cases, this may require re-creating the list.5. Now, in the main editor window, select the List placeholder and click on the (arrow) that appears in the upper-right corner. This will bring up the Common Content Tasks List, and then select Default to Master’s Content.Click Yes on the message box that appears.6. Then, you will want to select the PlaceHolderMain(Master) Content Place Holder, click on the that appears in the upper-right corner and select Create Custom Content.7. Next, click inside the PlaceHolderMain(Custom) and make sure that you can see the cursor inside the selected area.8. After this, in the SharePoint Designer File Menu, select Insert -> SharePoint Controls -> Custom List Form.9. In the pop-up box that appears, select the Computer Equipment Request list, and make sure that Item is selected for “Content type to use for form”. You’ll also want to make sure that New item form is the selected option. As for the Show standard toolbar checkbox, this depends on how you will be using your custom List Form, but for this example, uncheck this checkbox.10. After this, in the main edit window, you will now see a custom list form control that can be customized as needed.11. For our custom New Form, we need to remove the extra fields that we do not want the end-users to fill out (or see). To do this, select somewhere in the field row that you want to remove (in this case, the Status field). Then right-click and select Delete -> Delete Rows. This will then remove that field row from the custom list form control. Repeat this step for all the fields you want to remove.12. Once we have removed all fields we don’t want to be displayed, we are left with Request Name, Description, and Requested Equipment.13. Now that we have our custom NewForm looking how we want it to, we need to save it in SharePoint so that we can use it. To do this, click on the Save button, and then navigate to the Computer Equipment Request list and look for the original NewForm.aspx page. For this example, we are naming the page SubmitForm.aspx.14. Finally, we will want to set our custom NewForm (SubmitForm.aspx) as the default New item form for our list. To do this, go back to the Folder List window select the Computer Equipment Request list and right-click on it. From the menu that appears, select the Properties option.15. In the pop-up box, make sure that Item is selected for “Content type specific forms”. Then click on the Browse button for the New item form to select our custom SubmitForm.aspx.16. Now your custom NewForm page is ready for use. This is how it will appear to the end-user when they create a new item for the Computer Equipment Request list.By following the above instructions, you will be creating your own customized NewForm.aspx pages in no time using SharePoint Designer. The same techniques can also be applied to creating custom EditForm.aspx and DispForm.aspx pages.Next time, I’ll show you how to apply these concepts to creating multiple custom EditForm.aspx pages to use with different user roles.

Posted in Sharepoint | 1 Comment

Custom Site Theme for MOSS 2007 and WSS 3.0

A SharePoint site theme basically consists of theme.inf, theme.css, and image files. Theme.inf file simply represents the title of the theme. Theme.css is a stylesheet file that defines colors, header images and layouts of a site and image files can be referenced here to display on the page. By creating a custom site theme, you can easily change the style but in fact, writing and editing the stylesheet can be somewhat chanllenging when you have more than a hundred of elements to deal with.Here is a short procedure of creating a custom site theme named “Ghost”:1. Copy any theme folder in “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\THEMES” folder and paste with its name replaced with “Ghost”. In this example, copy GRANITE folder.2. In Ghost folder, rename GRANITE.INF file to GHOST.INF in upper case.3. Open GHOST.INF file with notepad.4. Change the value of title under [Info] to Ghost.5. Replace every word, Granite, under [titles] with Ghost.6. Open “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033\SPTHEMES.XML” file with notepad.7. Add the following lines under <SPThemes> tag:
<Templates>
  <TemplateID>Ghost</TemplateID>
  <DisplayName>Ghost</DisplayName>
  <Description>Ghost theme.</Description>
  <Thumbnail>images/thghost.gif</Thumbnail>
  <Preview>images/thghost.gif</Preview>
</Templates>
Notice that preview and thumbnail paths are images/thghost.gif. By default, MOSS 2007 and WSS 3.0 will not have such image files.8. In order to display thumbnail and preview correctly, you will need to capture the screen and save the file in “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\IMAGES” folder with thghost.gif name. You can change the .gif file name if you change the thumbnail and preview file names in <Templates> tag.9. Do an iisrest for the server to recognize the new theme.Pretty simple procedure. Now you are ready to test your new theme. In Site Settings, you can now choose Ghost theme; however, the theme will not differ from Granite theme. Now, it is time for you to play with theme.css file!

Posted in Sharepoint | Leave a comment

Define custom permission levels in SharePoint

Customize an existing permission level

If the custom permission level that you want is nearly identical to an existing default permission level and you don’t need to use the default permission level, you can customize the default permission level to include or exclude permissions that you do or do not need.1. On the Site Settings page, under Users and Permissions, click Advanced permissions.2. On the toolbar, click Settings, and then click Permission Levels.3. In the list of permission levels, click the name of the permission level you want to customize.4. In the list of or permissions, select or clear the check boxes to add permissions to or remove permissions from the permission level.5. Click Submit.

Copy an existing permission level

If the custom permission level that you want is similar to an existing default permission level, and you need to use both the default permission level and your custom permission level, you can copy the default permission level, and then modify the copy and save it as a new permission level.1. On the Site Settings page, under Users and Permissions, click Advanced permissions.2. On the toolbar, click Settings, and then click Permission Levels.3. In the list of permission levels, click the name of the permission level you want to copy.4. At the bottom of the page, click Copy Permission Level.5. On the Copy Permission Level page, in the Name box, type a name for the new permission level.6. In the Description box, type a description for the new permission level.7. In the list of permissions, select or clear the check boxes to add permissions to or remove permissions from the permission level.8. Click Create.

Create a permission level

If there is no permission level similar to the one you need, you can create one and include just the permissions that you need.1. On the Site Settings page, under Users and Permissions, click Advanced permissions.2. On the toolbar, click Settings, and then click Permission Levels.3. On the toolbar, click Add a Permission Level.4. On the Add a Permission Level page, in the Name box, type a name for the new permission level.5. In the Description box, type a description for the new permission level.6. In the list of permissions, select the check boxes to add permissions to the permission level.7. Click Create.

Posted in Sharepoint | Leave a comment

Exploring The SharePoint 12 Hive :TEMPLATE Directory.

We will take a look at the structure of the file system in SharePoint 2007 and how the files are used. As a developer you must know about the 12 HIVE folder.
If we look at a standard Microsoft Office SharePoint 2007 installation we can see that a new directory has been created under the following;
C:\Program Files\Microsoft Shared\Common Files\web server extensions
You will now see a 12 directory. This is known as the “12 HIVE” and is the directory that holds the necessary system files that drive SharePoint 2007.
The following directories can be found under the 12 hive;
ADMISAPI
BIN
CONFIG
HCCab
Help
ISAPI
LOGS
Resources
TEMPLATE
For the purposes of SharePoint development you will, for the majority of the time, be working with the TEMPLATE directory.

The TEMPLATE Directory Here is the structure under the TEMPLATE directory;

1033 – ADMIN – CONTROLTEMPLATES – Document Templates – FEATURES – GLOBAL – IMAGES – LAYOUTS – Pages – Site Templates – SQL – THEMES – XML

The TEMPLATE\1033 Directory : There are two directories that you need to know about here. The Workflow directory is where you will find the WSS.ACTIONS file. This file is used by SharePoint Designer 2007’s Workflow Designer. All of the workflows functions available to Designer are defined here. If you create workflow functionality using Visual Studio 2005/2008 and you want the functions to appear within the Workflow Designer, you will need to create a new .ACTIONS file.

The TEMPLATE\1033\STS Directory : The SharePoint Team Services or STS directory has one sub-directory within it. The DOCLIB directory contains several further sub-directories, each of which holds a template for a specific content type. There are templates for the Office applications, Word, Excel, PowerPoint and OneNote. There are also templates for the different types of page that can be created in SharePoint.

The TEMPLATE\1033\XML Directory : A more important directory within 1033 is the XML directory. Within this directory are several XML files.

Note : Changes to any of the file could be overwritten by SharePoint Service Packs.

DEADWEB.XML – This file is used during the site expiration process. Only change this file if you need to change the message that is displayed during the site expiration process.
RGNLSTNG.XML – This file holds the regional settings used by SharePoint 2007. You should not need to change this XML file.
WEBTEMP.XML – This file defines the pointers to the GLOBAL, STS, MPS, CENTRALADMIN, WIKI and BLOG site definitions. You can amend this file to either display or hide site templates during the New Site Creation process (newsbweb.aspx and scsignup.aspx).

WEBTEMPBDR.en-US.XML – This file defines the pointers to the BDR site definition. You can amend this file to either display or hide site templates during the New Site Creation process (newsbweb.aspx and scsignup.aspx).

WEBTEMPOFFILE.XML – This file defines the pointers to the OFFILE site definition. You can amend this file to either display or hide site templates during the New Site Creation process (newsbweb.aspx and scsignup.aspx).
WEBTEMPOSRV.XML – This file defines the pointers to the OSRV site definition. You can amend this file to either display or hide site templates during the New Site Creation process (newsbweb.aspx and scsignup.aspx).
WEBTEMPSPS.XML – This file defines the pointers to the SPS, SPSPERS, SPSMSITE, SPSTOC, SPSTOPICM, SPSNEWS, CMSPUBLISHING, BLANKINTERNET, SPSNHOME, SPSSITES, SPSCOMMU, SPSPORTAL, SRCHCEN, PROFILES, BLANKINTERNETCONTAINER and SPSMSITEHOST site definitions. You can amend this file to either display or hide site templates during the New Site Creation process (newsbweb.aspx and scsignup.aspx).
WEBTEMPSRCH.XML – This file defines the pointers to the SRCHCENTERLITE site definition. You can amend this file to either display or hide site templates during the New Site Creation process (newsbweb.aspx and scsignup.aspx).
It is preferable to clone and existing site definition and associated WEBTEMPxxx.XML file rather than edit an existing one. This will prevent your changes from being overwritten if a Service Pack is applied.
The final directory under 1033 is STS. This directory holds a subdirectory, DOCTEMP which contains further subdirectories that hold the definitions and templates for document types that are associated with document libraries. You will find templates for Microsoft Word, Excel and PowerPoint amongst others. You should not need to amend any of these files.

The TEMPLATE\ADMIN Directory : The files in the ADMIN directory are used by the Central Administration pages. There are three directories within ADMIN; 1033, Content Deployment and SSO. 1033\Policy\Report contains a reporting template and sample data. The Content Deployment directory contains the DeploymentUpload.aspx page. Finally, SSO contains all of the aspx pages for Single Service Sign-On. These files should not be amended.

The TEMPLATE\CONTROLTEMPLATES Directory : The CONTROLTEMPLATES directory is where the ASP.NET 2.0 control template files are held. Control templates are small re-usable files that contain components of a web page. An example is welcome.ascx. The welcome.ascx file defines the dropdown menu that appears under Welcome name on the top navigation section of a SharePoint 2007 page.
These pages are pulled into SharePoint 2007 aspx pages. You can create your own ascx pages.

The TEMPLATE\DocumentTemplates Directory : This directory contains one file, wkpstd.aspx, which is the base master file for Wiki pages.
Tips & Tricks : It is worth noting that although this page can be cloned and modified it will not be used by any Wiki page other than the first page that is created. This is because the wkpstd.aspx page is hard coded and is always used to create further Wiki pages.

The TEMPLATE\FEATURES Directory : The FEATURES directory holds subdirectories for each Feature that is available within SharePoint 2007. Each of these subdirectories will hold at least one file, feature.xml – this file will define the Feature and will have pointers to any other files required by the Feature.

The TEMPLATE\GLOBAL Directory : The GLOBAL directory holds two very important files; default.master and mwsdefault.master.
The default.master file is the master file that all files are based on. If you change this file, the change will be applied to every page that was created using an out-of-the-box site definition.

The mwsdefault.master file is the master file that all Meeting Workspace files are based on. If you change this file, the change will be applied to every Meeting Workspace page that was created using an out-of-the-box site definition.

The GLOBAL\XML directory holds the master ONET.XML file and master view XML files.
You should not need to modify any of the files within the Lists or XML directories at this time.

The TEMPLATE\IMAGES Directory : The IMAGES directory holds all images used within SharePoint 2007.

The TEMPLATE\LAYOUTS Directory : The LAYOUTS directory is another one of those directories that you should pay attention to. If you ever see /_layouts/ in the URL of one of your SharePoint sites, the aspx page will be in this directory. You will also notice the odd .ascx (control template), .js (JavaScript) and .master file within this directory. I am not sure why Microsoft didn’t tidy these files up and put them in more appropriate directories – as you become more familiar with SharePoint you will notice little inconsistencies like this.
In the LAYOUTS directory is application.master, the master file for all of the “admin” type pages, such as upload.aspx. When you begin to look at site customisation and branding you will see that application.master is one of the files that will need to be looked at.
The 1033\IMAGES directory : contains many of the images used in publishing sites, such as the thumbnails for each of the different pages types. There are also icons in this directory.
The 1033\STYLES directory : contains additional cascading style sheet (CSS) files.
The MOBILE directory : contains a series of aspx pages that are optimised for mobile devices.
The STYLES directory : contains one file, corefixup.css – more of an afterthought by Microsoft?

The TEMPLATE\Pages Directory : The Pages directory contains three aspx pages that are pulled in as subpages to other aspx pages.

The TEMPLATE\SiteTemplates Directory : A slightly misleading directory name as the SiteTemplates directory actually contains all of the SharePoint Site Definitions. It is in this directory that you would create any new site templates. There is a sub-directory for each site definition. Each sub-directory will contain at least an XML directory and a default.aspx file. The aspx file is the initial home page that is displayed when a site definition is used in SharePoint. The XML directory : will contain at least an ONET.XML file, which defines the setup of the site definition, such as which Features to load, where the web parts go and what they are, which document library templates to assign.
There will be extra files in some of the directories but they are used to provide the extra functionality that the site definitions require.
When creating new site definitions, you will place your directories here. Please have a look at our blog for creating custom site definitions in more detail.

The TEMPLATE\SQL Directory : The SQL directory contains a series of XML and SQL files. Some of these are used to define SharePoint configuration and content databases. You should not change these files.

The TEMPLATE\THEMES Directory : The THEMES directory contains 22 sub-directories, one for each theme that is available within SharePoint. Each sub-directory contains all of the files required for the theme, including all the images and the cascading style sheets.
You can create your own custom theme and place it within the THEMES directory. Please visit our blog Creating Custom Themes.

The TEMPLATE\XML Directory : The final directory, XML, contains XML and XSD files that are used in configuration of SharePoint. You shouldn’t need to venture in this directory, but if you do, be aware that any file you modify may be overwritten by SharePoint Service Packs.

alerttemplates.xml : Used to change the look and feel of Alert Notification emails for each list, web or custom types in your SharePoint Environment. You can set custom branding based on your to your email alerts.

BASE.XML : defines base types for lists that apply globally to all the SharePoint Web sites.

DOCICON.XML : This file is used for mapping file types to particular icons. To add the new icon to the file type follow below steps.
1). To add a .pdf (Adobe PDF) file name extension, add the following line to the ByExtension section in this file—

‘<‘ Mapping Key=”pdf” Value=”pdf16.gif”/ ‘>’.
2). Add the file pdf16.gif (use Google Image Search to get this image) to the Program Files\Common Files\Microsoft Shared\web server extensions\12\Template\Images.

FLDTYPES.XML : Used to define how various SharePoint field types are rendered.

fldtypes_hold.xml : Used to define the hold status pertaining to entities realted to Records Management Policy. Note: This file is meant for internal use and it is recommended not alter the contents.

fldtypes_publishing.xml : Used to define the publishing field types like HTML, Links, Summary Links etc. In case of creating a new custom publishing field type, say Address (with validation) then a new entry related to this filed type has to be added to this file.All other xml files with prefix fldtypes are cutom built field types. Yet another notable field type is Business Data field. This field type is defined in fldtypes_spsbizdata.xml.

htmltransinfo.xml : Used to define the how to open various documents stored in the sharepoint server. The mapping entry for a particular document in this XML file will tell SharePoint server to open the document in a particular client application. If the document conversion mapping is not found in this file, SharePoint will prompt the user to download the document.

SharePoint is flexible enough for you to create custom properties by creating custom XML files in this directory.

This is a good start for you to go off exploring further in TEMPLATES Directory.

Posted in Sharepoint | Leave a comment

Directory Structure In The 12 Hive

The 12 hive is where everything in SharePoint happens and is where all the binaries, configuration, web pages, web controls, help files and other resources reside. As a developer writing your own features for SharePoint, it is vital that you learn where things go and where you should be targeting your resources.This article however is aimed at an administrator and developer with a basic overview of what you can find where. 

Below is a list of core folders in the 12 hive.\ADMISAPI : The directory contain the web service used used by the SharePoint Central Administration and appears as a virtual directory.\BIN : The directory contains all the core binary files, utilities that are used by Windows SharePoint Services. Your command line tools such as STSADM.EXE reside in this folder.\BIN\LCIDD : A directory will be created for each language, which contains language specific binary files.\CONFIG : This directory contains a set of configuration, binary and resource files used by SharePoint. Some files are the default values which will be copied to web site instances.\DATA : SharePoint uses this directory structure for the indexing services where content will be indexed.\HCCab\LCID : This directory has a set of cab files containing manifest and content information used by the SharePoint help system.\Help : The folder contains a compiled html help file (.chm) used by the configuration wizard.\ISAPI : This directory contains all the standard Web Services for SharePoint and some additional DLL’s, resources and configuration files that the web services use. Every web application provisioned in SharePoint will have a virtual directory “_vti/_bin” that points to this directory, thus giving each web application it’s own set of web services.\ISAPI\HELP : This directory contains all the help files used by SharePoint. The folder also contains LCID sub directories for each language installed thus globalizing the help system.\LOGS : This is the directory that you will be visiting frequently while doing development and administration as it contains the log files of what SharePoint did and what errors occurred.\Resources : This directory contains the core.resx file used for creating language packs for SharePoint. If you are going to be localizing your SharePoint sites with different languages and cultures, this is the folder to do it in.\TEMPLATE : This directory structure contains the core web site functionality in SharePoint, that is the features, templates, configurations, resources of a web site. What is important to note about this directory structure is that the Virtual Path Provider hides and masks this directory structure, thus it appears under each web site, list in a completely different structure. As a SharePoint developer you should completely familiarize yourself with this folder structure.

Posted in Sharepoint | Leave a comment

Customizing List View Web part using XSLT Data View

I always detested that when you convert a standard SharePoint Web Part, that shows totals for columns (count, sum, etc.), into an XSLT dataview web part within SharePoint Designer, the totals disappear.  This never made much sense to me, as every other part of the view is translated into the appropriate XSLT code.  So this post will discuss how to put those totals back in.When you group by a field in XSLT, the header for each group boils down to displayingTo resolve this problem just follow the steps  

Step 1: Add List View Web part on SharePoint webpart page as shown in the fig

Step 2: Select Modify Shared Web part and edit current view of listview web part as shown in the fig

Step 3: Select Only ID column as Shown in the fig

Step 4: Expand Group By Field and select Status column

 

Step 5: Expand Total Field and Select ID Total equal to count

 

Step 6: Set Toolbar equal to No Toolbar

 

Step 7: Now ListView webpart looks like as shown in the fig

Step 8: Open Default.aspx page in sharepoint designer 

 Step 9: Convert Listview webpart into xslt view as shown in the figJust right click on listview webpart and select convert to XSLT Data view

 

Step 10: Add additional code after group by field to show row count<xsl:value-of select=”count(/dsQueryResponse/Rows/Row[@Status = $fieldvalue])”/>Original code:<xsl:otherwise><xsl:value-of select=”$fieldvalue”></xsl:value-of>Modifying Code:<xsl:otherwise><xsl:value-of select=”$fieldvalue”></xsl:value-of> [<xsl:value-of select=”count(/dsQueryResponse/Rows/Row[@Status = $fieldvalue])”/>]</xsl:otherwise> 

Step 11: Show total row counts in the current view just add following line<b style=”padding-left:10px;padding-top:5px; font-family:Tahoma;font-size:8pt;font-weight:700;”>Total Calls :[<xsl:value-of select=”count(/dsQueryResponse/Rows/Row)”/>]</b>

Step 12: Remove ID Column from XSLT view as highlighted in the screen dump

 

Step 13: Job is done now List view webpart only show row count according to status wise (Group by Field wise) without any field displaySo I am counting (for each header) the number of items where the list item value for the Day field equals the current group header value. The final result is shown below

 

Njoy !!!!

Posted in Sharepoint | 4 Comments

Dynamically Add ASP.NET AJAX SlideShow Extender User Control on Button click event of aspx page

In ASP.NET AJAX Control toolkit there is an extender known as SlideShowExtender. AJAX SlideShow extender takes the ID of image control of ASP.Net to display the images in it according to the time interval fixed for it. You can also specify the auto start event to change the images in SlideShow extender when the page loads. Also you can enable the loop to run the SlideShow in continuous manner that loads the first image again after displaying the last image and plays the SlideShow repeatedly.

The AJAX SlideShow extender also has features to associate Button controls of ASP.Net  to stop/play or viewing the next and previous image in the slide show. Associated button controls allow the users to stop the automated running Slide show and view the images manually by using next/ previous buttons.

AJAX SlideShowExtender Properties

TargetControlID: ID of the Image control to display the images of SlideShow program.AutoPlay: Enables the feature to start to SlideShow automatically when page loads.ImageTitleLabelID: ID of the Label control to display the Title/Name of the image.ImageDescriptionLabelID: ID of the Label control to display the Description of the image.NextButtonID: ID of the Button control to view the next image.PlayButtonID: ID of the Button to play the SlideShow. Play Button performs the two functions. When user clicks on play button it plays the slide show and changes the text of the Play Button according to the property of AJAX SlideShow extender StopButtonText. When user again clicks on the PlayButton it stops the SlideShow.PlayButtonText: Text to be displayed on the PlayButton e.g.: PlayStopButtonText: Text to be displayed on the PlayButton to stop the SlideShow. By Default PlayButton displays the PlayButtonText when user clicks the PlayButton to view the Slide Show then its Text changes to StopButtonText.PreviousButtonID: ID of the Button to view the previous image.Loop: If Loop is set to true then it plays the SlideShow in repeat/continuous order.SlideShowServiceMethod: Name of the page script web service method to pass the array of Slide Show images,You can use any method name for WebMethod but its return type should be of AjaxControlToolkit.Slide[].Sample Example:1.Create one UserControl  for AJAX SlideShow extender as shown in the figFig1:Design Code For Slideshow extender UserControl Design Code<%@ Control Language=”C#” AutoEventWireup=”true” CodeFile=”Animation.ascx.cs” Inherits=”Animation” %>
<%@ Register Assembly=”AjaxControlToolkit, Version=3.0.30930.28736, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e”
    Namespace=”AjaxControlToolkit” TagPrefix=”cc1″ %><div>
        <!–Add a script manager in your page –>
        <asp:ScriptManager ID=”ScriptManager1″ runat=”server”>
        </asp:ScriptManager>
        <asp:UpdatePanel ID=”UpdatePanel1″ runat=”server”>
        <ContentTemplate>
        <center>
            <!–This is the initial image that will be shown to the user –>
             <asp:Image ID=”ImagePlayer” runat=”server” ImageUrl=”~/image/loading.gif”/>
             <br />
             <!–Previous, Next Button to see the previous, next image and Play and  stop button to start and stop the  slide show –>
             <asp:Button ID=”btnBack” runat=”server” Text=”Back” />
             <asp:Button ID=”btnPlay” runat=”server” Text=”Play” />
             <asp:Button ID=”btnNext” runat=”server” Text=”Next” /><br />
            <!–Drag and Drop a SlideShowExtender –> 
             <cc1:SlideShowExtender ID=”SlideShowExtender1″ runat=”server” TargetControlID=”ImagePlayer”
                 Loop=”true” NextButtonID=”btnNext” AutoPlay=”true” PlayButtonID=”btnPlay” PlayButtonText=”Play”
                PreviousButtonID=”btnBack” SlideShowServicePath=”SlideShowService.asmx” SlideShowServiceMethod=”GetSlides”
                StopButtonText=”Pause”  PlayInterval=”500″ >
             </cc1:SlideShowExtender>
             <br />
         </center>
         </ContentTemplate>
         </asp:UpdatePanel>
</div> 2.Create SlideService.asmx web service create a Web method  its return type should be of AjaxControlToolkit.Slide[].You must use [System.Web.Script.Services.ScriptMethod] to allow the SlideShowExtender to access the WebMethod.C# WebService Method Code using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.IO;
using System.Collections;/// <summary>
/// Summary description for SlideShowService
/// </summary>
[WebService(Namespace = “http://tempuri.org/”)]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class SlideShowService : System.Web.Services.WebService {    public SlideShowService () {        //Uncomment the following line if using designed components
        //InitializeComponent();
    }    #region Get Image Path For Slideshow
    [WebMethod(EnableSession = true)]
    public AjaxControlToolkit.Slide[] GetSlides()
    {
        AjaxControlToolkit.Slide[] mySlides;
        try
        {
            string FolderPath = Convert.ToString(Application[“FolderPath”]);
            int strStart = Convert.ToInt32(Application[“Start”]);
            int strEnd = Convert.ToInt32(Application[“End”]);
            int size = 0, cnt = 0,cnt1 = 0;            if (strStart > strEnd) { cnt = strEnd; cnt1 = strStart; size = strStart – strEnd; }
            else if (strStart < strEnd) { cnt = strStart; cnt1 = strEnd; size = strEnd – strStart; }
            else { cnt = strStart; cnt1 = strEnd; size = 1; }            mySlides = new AjaxControlToolkit.Slide[size + 1];
            FolderPath = FolderPath.Substring(FolderPath.IndexOf(“/”) + 1);
            for (int i = cnt, j = 0; i <= cnt1; i++)
            {
                string filename = i + “.jpg”;
                string strFilePath = FolderPath + filename;
                mySlides[j] = new AjaxControlToolkit.Slide(strFilePath, filename, filename);
                j++;               
             }
           }
            catch (Exception ex)
            {
                 mySlides = new AjaxControlToolkit.Slide[1];
                 mySlides[0] = new AjaxControlToolkit.Slide(“image/NoImage.jpg”, “NoImage”, “NoImage”);
            }
        return mySlides;
    }
    #endregion}

3.Now Dynamically Add Slideshow User Control on Button click event of aspx page C# Code#region Dynamically Add Animation User Control
    protected void btnAnimation_Click(object sender, EventArgs e)
    {
        try
        {
            stStart = txtStartDate.Text;
            stEnd = txtEndDate.Text;            string strParam = ddParameter.SelectedItem.Value.ToString();
            GetFolderPath(strParam);            string strDate = txtStartDate.Text;
            string st1 = strDate.Substring(0, 2);
            string st2 = strDate.Substring(3, 2);
            string st3 = strDate.Substring(6, 4);
            Application[“Start”] = st3 + st2 + st1;            string strEnd = txtEndDate.Text;
            string st4 = strEnd.Substring(0, 2);
            string st5 = strEnd.Substring(3, 2);
            string st6 = strEnd.Substring(6, 4);
            Application[“End”] = st6 + st5 + st4;            string UserControlPath = “~/Animation.ascx”;
            UserControl LoadedControl = new UserControl();
            PlaceHolder1.Controls.Add(LoadedControl.LoadControl(UserControlPath));
        }
        catch (Exception ex)
        {        }
        finally
        {
            txtStartDate.Text=stStart;
            txtEndDate.Text=stEnd;
        }
    }
    #endregion

Now select start and end date in calendar control and click Start Animation button.

Thats it…Njoy!!

Posted in ASP.Net | 2 Comments

Communicate SharePoint Lists Webservice In Asp.Net Site

This is the first long article I’m writing based on SharePoint technologies. It’s aimed at reasonable .Net developers who are looking to get started developing around SharePoint technologies. By no means is everything I say in the best approach. If you spot something that should be done another way please do mention it in the comments! SharePoint is such a big application and topic we’re all learning as we go along.

A full list of webservice methods for things such as alerts and sites are available in the SharePoint Products and Technologies 2003 SDK. I’ll hopefully cover them all in time, but today we’ll focus on just the list webservice.

You can navigate to the webservice discovery file by typing in :

localhost/sitename/_vti_bin/lists.asmx?wsdl

Here are the methods and their definitions as taken from the SDK:

  • AddAttachment – Adds an attachment to the specified list item in the specified list.
  • AddList – Creates a list in the current site based on the specified name, description, and list template ID.
  • DeleteAttachment – Removes the attachment from the specified list item.
  • DeleteList – Deletes the specified list.
  • GetAttachmentCollection – Returns a list of the URLs for attachments to the specified item.
  • GetList – Returns a schema for the specified list.
  • GetListAndView – Returns the list and view schemas for the specified list.
  • GetListCollection – Returns the names and GUIDs for all the lists in the site.
  • GetListItemChanges – Returns changes made to the list since the specified date and time.
  • GetListItems – Returns information about items in the list based on the specified query.
  • UpdateList – Updates a list based on the specified field definitions and list properties.
  • UpdateListItems – Adds, deletes, or updates the specified items in a list on the current site.

 

Add ListItem and attachment To list through webservice

Here i am giving sample example  where end user add calls[issues] in call register[SharePoint List] in Asp.Net Web site.

Following is the screen which can be used to insert a call (queries, issues) into call register.

Fig 1: Landing Page

Add ListItem

When user click on add call following screen is shown. With the help of screen is shown user can add call in call register .

Fig 2:Add List items.

On button submit click value stored in one wrapper class  and Communicate with SharePoint webservice as follow

Fig 3: Value stored in to the class object

And Now Pass this class object to Interface[wrapper class] in which using the SharePoint List WebService to insert an item into a list.

namespace CallRegisterInterface
{
    public class CallRegisterWebservice
    {
        //THIS IS GENERIC FUNCTION USED TO ADD THE ITEM TO LIST.
        public void AddNewCalls(clsCallRegister objCallRegister)
        {
            try
            {
                CallRegisterInterface.WSSCallRegister.Lists wsList = new CallRegisterInterface.WSSCallRegister.Lists();
                string listName = ConfigurationSettings.AppSettings[“WssCallRegisterList”];
                string wssUserName = ConfigurationSettings.AppSettings[“WssUserName”];
                string wssPassword = ConfigurationSettings.AppSettings[“WssPassword”];
                string wssDomain = ConfigurationSettings.AppSettings[“WssDomainName”];
                wsList.Credentials = new System.Net.NetworkCredential(wssUserName, wssPassword, wssDomain);               
                string fileName = objCallRegister.Content;            
                if (fileName !=string.Empty || fileName !=””)
                {
                    fileName = fileName.Substring(fileName.LastIndexOf(“\\”) + 1);                  
                }       
                //Create the batch file to add new item to list.
                string strBatch = “<Method ID=’1′ Cmd=‘New’>” +
                   “<Field Name=’Title’>” + objCallRegister.DealerCode + “</Field>” +
                   “<Field Name=’Issuing_x0020_Date’>” + objCallRegister.IssuingDate + “</Field>” +
                   “<Field Name=’Dealer_x0020_Name’>” + objCallRegister.DealerName + “</Field>” +
                   “<Field Name=’UserID’>” + objCallRegister.UserId + “</Field>” +
                   “<Field Name=’Module’>” + objCallRegister.ModuleName + “</Field>” +
                   “<Field Name=’Program_x0020_Name’>” + objCallRegister.ProgramName + “</Field>” +
                   “<Field Name=’Brief_x0020_Error’>” + objCallRegister.BriefError + “</Field>” +
                   “<Field Name=’Problem_x0020_Description’>” + objCallRegister.ProblemDescription + “</Field>” +
                   “<Field Name=’Role_x0020_Name’>” + objCallRegister.RoleName + “</Field>” +
                   “<Field Name=’Status’>New</Field>” +
                   “<Field Name=’Call_x0020_Priority’>”+objCallRegister.Priority+”</Field>” +
                   “<Field Name=’Reporting_x0020_Person_x0020_Nam’>” + objCallRegister.ReportingToName + “</Field>” +
                   “<Field Name=’Reporting_x0020_Person_x0020_Ema’>” + objCallRegister.ReportingToEmailID + “</Field>” +
                   “<Field Name=’Estimated_x0020_Completion_x0020′>” + null + “</Field>” +
                   “<Field Name=’Solution_x0020_Provided’>-</Field></Method>”;
               

                XmlDocument xmlDoc = new System.Xml.XmlDocument();
                System.Xml.XmlElement elBatch = xmlDoc.CreateElement(“Batch”);
                elBatch.SetAttribute(“OnError”, “Continue”);
                elBatch.SetAttribute(“ListVersion”, “1”);
                elBatch.InnerXml = strBatch;
                XmlNode ndReturn = wsList.UpdateListItems(listName, elBatch);
                if (ndReturn.ChildNodes.Item(0).InnerText != “0x00000000”)
                {  
                }
                else
                {
                    //Add attachment to the list
                    if (fileName != string.Empty || fileName != “”)
                    {
                        byte[] fileContents = objCallRegister.FileContent;                      
                        string return_value = wsList.AddAttachment(listName, ndReturn.SelectSingleNode(“//@ows_ID”).Value, fileName, fileContents);
                        wsList.Dispose();
                    }                  
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

My Calls

When user click on My Call following screen is shown. With the help of screen is shown user can view calls in call register.

  

         Fig 4:View ListItem in Gridview 

On Page Load event we call GetListData function to communicate with sharepoint web service GetListItems Webmethod  as follow and return dataset  and we bind dataset to gridview control

//THIS IS GENERIC FUNCTION USED TO RETRIEVE LIST ITEM.
       public DataSet GetListData()
       {

           CallRegisterInterface.WSSCallRegister.Lists wsList = new CallRegisterInterface.WSSCallRegister.Lists();
           string strUserID = GlobalData.UserID.ToString();          
           string listName = ConfigurationSettings.AppSettings[“WssCallRegisterList”];
           string wssUserName = ConfigurationSettings.AppSettings[“WssUserName”];
           string wssPassword = ConfigurationSettings.AppSettings[“WssPassword”];
           string wssDomain = ConfigurationSettings.AppSettings[“WssDomainName”];
           wsList.Credentials = new System.Net.NetworkCredential(wssUserName, wssPassword, wssDomain);

           //xmldocument to create necessary nodes for getalllistitems method..
           XmlDocument xdoc = new XmlDocument();
           XmlNode queryNode = xdoc.CreateNode(XmlNodeType.Element, “Query”, “”);

           string strQuery = @”<Where><And><And><IsNotNull><FieldRef Name=’Title’ /></IsNotNull>” +
                             “<Neq><FieldRef Name=’Status’ /><Value Type=’Choice’>Closed</Value>” +
                             “</Neq></And><Eq><FieldRef Name=’UserID’ /><Value Type=’Text’>” + strUserID + “</Value></Eq></And></Where>”+
                              “<OrderBy><FieldRef Name=’ID’ Ascending=’False’ /></OrderBy>”;

           //get all list items whose id is greater than zero i.e all list item..           
           queryNode.InnerXml = strQuery;
           XmlNode viewNode = xdoc.CreateNode(XmlNodeType.Element, “ViewFields”, “”);
           string strViewFields = “”;//for all fields”<FieldRef Name=\”ID\” /><FieldRef Name=\”Title\” />”;
           viewNode.InnerXml = strViewFields;
           XmlNode nodeQueryOption = xdoc.CreateNode(XmlNodeType.Element, “QueryOptions”, “”);
           nodeQueryOption.InnerXml = “<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns><DateInUtc>TRUE</DateInUtc>”;
           string rowlimit = “100”;
           string webid = “”;

           //get items from test sharepoint list..
           XmlNode xmlnodeinput = wsList.GetListItems(listName, “”, queryNode, viewNode, rowlimit, nodeQueryOption, webid);
           wsList.Dispose();

           XmlDocument wdoc = new XmlDocument();
           wdoc.LoadXml(xmlnodeinput.InnerXml);
           DataSet ds = new DataSet();
           DataTable dt = new DataTable();
           using (XmlReader reader = new XmlNodeReader(wdoc.DocumentElement))
           {
               ds.ReadXml(reader);
               reader.Close();
           }
           return ds;
       }

Binding Dataset with Gridview

                                                                          

Fig5: Binding Gridview 

When user wants to edit existing added listItem following screen appears,

Fig

6:Update Existing ListItem through webservice.

Following sample code for How to update an Existing SharePoint list item using a CAML Query to the SharePoint Lists

//THIS IS GENERIC FUNCTION USED TO UPDATE THE ITEM TO LIST.
        public void UpdateItemtoList()
        {
            try
            {
                CallRegisterInterface.WSSCallRegister.Lists wsList = new CallRegisterInterface.WSSCallRegister.Lists();
                string strUserID = GlobalData.UserID.ToString();
                string listName = ConfigurationSettings.AppSettings[“WssCallRegisterList”];
                string wssUserName = ConfigurationSettings.AppSettings[“WssUserName”];
                string wssPassword = ConfigurationSettings.AppSettings[“WssPassword”];
                string wssDomain = ConfigurationSettings.AppSettings[“WssDomainName”];
                wsList.Credentials = new System.Net.NetworkCredential(wssUserName, wssPassword, wssDomain);

                string fileName = clsCallRegister.UpdateContent;               
                if (fileName != string.Empty || fileName != “”)
                {
                    fileName = fileName.Substring(fileName.LastIndexOf(“\\”) + 1);                 
                }                  

                //Create the batch file to update item to list.
                string strBatch = “<Method ID=’1′ Cmd=‘Update’>” +
                   “<Field Name=’ID’>” + clsCallRegister.UpdateItemID + “</Field>” +
                   “<Field Name=’Module’>” + clsCallRegister.UpdateModuleName + “</Field>” +
                    “<Field Name=’Issuing_x0020_Date’>” + clsCallRegister.UpdateIssuingDate+ “</Field>” +
                   “<Field Name=’Program_x0020_Name’>” + clsCallRegister.UpdateProgramName + “</Field>” +
                   “<Field Name=’Brief_x0020_Error’>” + clsCallRegister.UpdateBriefError + “</Field>” +
                   “<Field Name=’Problem_x0020_Description’>” + clsCallRegister.UpdateProblemDescription + “</Field>” +
                   “<Field Name=’Role_x0020_Name’>” + clsCallRegister.UpdateRoleName + “</Field>” +
                   “<Field Name=’Status’>”+clsCallRegister.UpdateStatus+”</Field>” +                 
                   “<Field Name=’Reporting_x0020_Person_x0020_Nam’>” + clsCallRegister.UpdateReportingToName + “</Field>” +
                   “<Field Name=’Reporting_x0020_Person_x0020_Ema’>” + clsCallRegister.UpdateReportingToEmailID + “</Field></Method>”;

                XmlDocument xmlDoc = new System.Xml.XmlDocument();
                System.Xml.XmlElement elBatch = xmlDoc.CreateElement(“Batch”);
                elBatch.SetAttribute(“OnError”, “Continue”);
                elBatch.SetAttribute(“ListVersion”, “1”);
                elBatch.InnerXml = strBatch;
                XmlNode ndReturn = wsList.UpdateListItems(listName, elBatch);              
                if (ndReturn.ChildNodes.Item(0).InnerText != “0x00000000”)
                {
                }
                else
                {
                    //Delete Existing Attachment
                    if (fileName != string.Empty || fileName != “”)
                    {
                        if (clsCallRegister.UpdateDeleteAttachment)
                        {
                            XmlNode ndAttach = wsList.GetAttachmentCollection(listName, ndReturn.SelectSingleNode(“//@ows_ID”).Value);
                            XmlNodeList ndsAttach = ndAttach.ChildNodes;
                            for (int i = 0; i < ndsAttach.Count; i++)
                            {
                                string delUrl = ndsAttach[i].InnerText;
                                wsList.DeleteAttachment(listName, ndReturn.SelectSingleNode(“//@ows_ID”).Value, delUrl);
                            }                          
                        }
                        //Uploading New Attachment
                        byte[] fileContents = clsCallRegister.UpdateFileContent;                     
                        string return_value = wsList.AddAttachment(listName, ndReturn.SelectSingleNode(“//@ows_ID”).Value, fileName, fileContents);
                        wsList.Dispose();                      
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

Happy Coding !!

Posted in Sharepoint | Leave a comment