Click here to Skip to main content
Licence CPOL
First Posted 25 Mar 2009
Views 53,137
Bookmarked 15 times

Multiple Edit Form for Sharepoint List Item

By MJ Ferdous | 9 May 2009
How to customize New or Edit Form (NewForm.aspx or EditForm.aspx). How to make multiple custom edit form for different item status. How to link those Forms with the list item by creating custom link column
1 vote, 14.3%
1

2

3
2 votes, 28.6%
4
4 votes, 57.1%
5
4.21/5 - 7 votes
μ 4.21, σa 2.80 [?]

Introduction

This article is useful for the following reasons:

  • To create a List Definition template using Visual Studio .NET 2005/2008 extension for WSS
  • To create a custom hyperlink column using schema.xml where the hyperlink will be built dynamically depending on the value of another field (in this example, I used Issue status column)
  • To customize the edit form (EditForm.aspx) and also new form (NewForm.aspx)
  • To make more than one edit form for different issue item status

When you want to enter an edit item into, let’s say, your Issue Tracker list, SharePoint calls upon the EditForm.aspx page for that list. The page contains a customized List Form Web Part which cannot be edited within the web part, so in order to accomplish this, I use SharePoint Designer 2007 tool and Visual Studio .NET extension for SharePoint List Definition Template. Also I explain how to make different Edit form and depending on the list status, the edit link will redirect in different edit page. Here is the technique to do it.

Background

During my Bug Tracker website development on MOSS platform, one of the tasks was how to customize the edit view of issue tracker list for the user of the site and also make different edit form for different issue status. EditForm.aspx page contains a List Form Web Part which displays default columns associated with the Issue Tracker list properties. The first problem was to customize edit form because of default webpart and the second problem was to make a different edit view depending on status. Also the last problem was to link different edit view for different status. I solved the problem one after another with the help of other online articles and my colleague.

To Create and Customize Custom Edit/New Forms for SharePoint Lists

  • Open your site into SharePoint Designer.
  • Go to your target list and open the 'NewForm.aspx' web form.
  • Go File > Save As... and give the form a new name such as 'NewForm2.aspx'.
  • Delete the default List Form Web Part from the page.
  • Go Insert > SharePoint Controls > Custom List Form.
  • In the List or Document Library Form dialog, select the appropriate list, content type and type of form.
  • Click OK and a new Data Form Web Part is added with controls representing all the fields from the list.
  • Now, you can do your customization such as rearranging the fields according to your need.
  • Save the site.

EditForm.GIF

EditForm2.GIF

Create a List Definition Template

You have to create a List Definition project of your specific list type (task, issue) for which you want to customize. Here, we will create Issue Tracking typelist definition using VS.NET Extension for WSS.

File > New > Project

  • Select Visual C# (From the Dialog)
  • Select Empty project
  • OK (Give project name “ListDefinitionDemo”)
  • Add New Item (IssueListDemo)
  • Select Issue Tracking from the List Definition Settings Dialog.
  • OK.
  • Build the project.
  • If the build succeeds, go to Project Properties -> Debug.
  • Provide site URL in “Start Browser With URL” under Set Action.
    e.g. http://servername:port/websitedemo
  • Deploy Solution.

If your deployment is successful, then the next step is to customize schema.xml file for custom column.

Note: The list will be deployed in the following location: C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES.

Create Custom Hyperlink Column

After creating the solution using Visual Studio .NET, it is necessary to add customize edit column in schema.xml to build dynamic hyperlink so that the user can see the actual edit form layout (different edit page, e.g. EditPage1.aspx) depending on the item status. Add a new hyperlink column and build a dynamic href link in the following way:

<view url="MyItems.aspx" webpartzoneid="Main" type="HTML" baseviewid="2">
        <viewfields>
            <fieldref name="Attachments">
            </fieldref>
            .    .    .
            <fieldref name="CustomEdit">
            </fieldref>
        </viewfields>
        .     .    .
</view>

The sample code would look like this which you have to add inside <!--<fields>…</fields> -->: Put new GUID id for field ID using guidgen.exe tool from VS.NET command tool.

<fields>
    .    .    .
<field id="{CEA7C7CF-238E-48c1-8DEA-F1ED2D038C0E}" name="CustomEdit"
        type="Computed" hidden="FALSE" readonly="TRUE" displaceonupgrade="TRUE"
        displayname="Modify" classinfo="Menu"
        sourceid="http://schemas.microsoft.com/sharepoint/v3" staticname="CustomEdit" 
        frombasetype="TRUE">
        <fieldrefs>
          <fieldref name="ID">
          <fieldref name="Status">
        </fieldrefs>
        <displaypattern>
        </displaypattern>
      </field>
</fields>

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

MJ Ferdous

Architect
Congral LLC
Bangladesh Bangladesh

Member
MJ Ferdous is an IT professional from 8 years ago.
 
He is working as Technical Project Manager of Congral LLC, USA and SharePoint Consultant as well. He has industry level experience on SharePoint and did lots of Presentation & workshop on SharePoint.
 
Before join in Congral, he did work in OT Group SPA, Italy as SharePoint Consultant, Rockwell Automation-Italy as Project Engineer and many others .net companies. He did work on many international projects during his professional life. The major projects are included below:
Shared Care Plan for Congral LLC, USA
Internet Banking Portal for BANCA CREDEM, Italy
MES solution for Rockwell Automation, Italy
Tourism for Travel Curve Inc., USA
and so on...
 
He is the author of several technical articles. More Than 50 articles are published in mrbool.com as Technical Author of that site. He is also owner & moderator of several groups of SharePoint and asp.net.
 
Looking for a Offshore Development or partnership.............. in any development in Dot.Net & Sharepoint 2007,2010 Platform.
 
Search him in google by 'MJ Ferdous' to get all links, articles, profile etc
Contact him: ferdous_cs [at] yahoo.com
His blog: http://geekswithblogs.net/ferdous
His personal site: http://mjferdous.com

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 4 PinmemberSanjeevSingh21:12 31 Oct '11  
GeneralHI can you do depending on he user logged in PinmemberMadelghattas2:10 17 Mar '11  
GeneralMultiple Edit Pinmembermoss4rea0:32 14 Aug '09  
GeneralMy vote of 1 Pinmemberchicken_chicken4:30 21 May '09  
No explanations at all, read first comment to see why.
GeneralArticle content is Incoherent with its introduction PinmemberMoim Hossain22:10 21 Apr '09  
GeneralRe: Article content is Incoherent with its introduction PinmemberMJ Ferdous10:40 25 Apr '09  
GeneralRe: Article content is Incoherent with its introduction Pinmemberjess10122:02 6 Oct '10  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120210.1 | Last Updated 9 May 2009
Article Copyright 2009 by MJ Ferdous
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid