Wednesday 3 February 2010

Data View Web Part- Update the List

I got a requirement in which the client manager want to present the user with a contactform. And want to track the submitted data in the portal. And the main requirement is to use Out of Box features without much delay and with branding imposed.Then I prefered to use data view web part to achieve this solution in less than 1 hour.

Steps to achieve this quick solution.

1) Open the page in Sharepoint designer

2) Click on Insert->Sharepoint Controls->Data View web part to the page.

3) Data source library would be displayed(if not displayed, choose from Task Panes)

4) Select the required "List Name" from the displayed data sources, as shown here


5) Click on "Show data" in the context menu displayed when right-clicked on the "List Name"

6) Fields and their data would be displayed in the column "Current Data source"

7) Highlight Rows

8) Click on the "Insert Selected Fields as" to display dropdown.


9) Click on "New Item form"

10) Automatically SharePoint Designer embeds the field controls with their field name.

11) Save the page & publish changes

12) Navigate to the page in Browser and test it

Some more customizations

1) I created a list which has four columns (FullName(text), Contact(text), Email(text), Phone(text))

2) Inserted the data view web part as detailed in above steps.

3) Now after step 10, Right click on the text controls generated for more options

4) Choose as text box.
Or replace the entire line of
<sharepoint:formfield runat="server"....
with
<asp:TextBox runat="server" id="ff1{$Pos}" __designer:bind="{ddwrt:DataBind('i',concat('ff1',$Pos),'Text','TextChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Title')}" BorderColor="#25a5cc" BorderStyle="Solid" BorderWidth="1px" />

5) Save the changes and refresh the browser, then we can see the excellent form control which would update the data into the list



6) And we can even regular asp validator controls to validate and impose the mandatory field checks. This can also be achieved by making that field compulsary in List

7) To check whether the email field has a valid email address, add the following line after the Email field control
<asp:RegularExpressionValidator runat="server" ErrorMessage="Invalid Email !" id="RegularExpressionValidator1" ControlToValidate="ff2{$Pos}" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" />

* You can customize the errormessage also.

8) Now save the changes and refresh the browser to see the result.

9) On entering the in correct data, the Email field throws the error message and prevents user from saving the data.






Cheers! Am done.

Enjoy SPD'ing

**************************************************************************************


Refer this link for displaying the list data in the data view web part

Monday 25 January 2010

Common Errors with SharePoint and their Solutions

I thought to create a ground for listing out most of the MOSS errors I have encountered and their solutions, so that they might be useful to some of the MOSS developer buddies.
And this list would be appended as I encounter the issues and their resolutions.

************************************************************************************************
#1)Connecting the Portal with sharepoint designer
The first error I encountered when trying to open the Portal using Sharepoint Designer is as follows:
"The Folder xxxxxx isint accessible. The folder might be located in unavailable location,protected with a password, or the file name contains a/ or \".

After struggling with issue for a while, I found that there are a quite a few locations in Central Administration which will help us to resolve this error.

    Steps Of resolution:

1) Log into Central Administration
2) Navigate to Applications -- > Application Security -- User permissions for Web Applications.
3) Select this option
"Use Remote Interfaces - Use SOAP, Web DAV, or SharePoint Designer interfaces to access the Web site"
3) Navigate to Applications-- > Application Security -- Authentication Providers
4) Choose the appropriate zone and click on that
5) Choose "YES" for Enable Client Integration

It did the trick and after that am able to connect to the portal with SPD without any issues.
************************************************************************************************