5

I have two content types created A and B. I have a list definition where I placed those content types. Using SPD 2010, I created a custom list edit form and as you know, SPD 2010 will ask you to bind it with a content type, so I selected A. Then I copied it and with some modifications added it to VS 2010 project.

When the feature is activated,during editing list item I see fields from content type A but I am not able to edit fields from content type B because there is no dropdown on top which lets me select a content type from A or B.

So I wanted to know if it is possible to have that content type selected dropdown in here in a custom list form in list definition.

2 Answers 2

1

When creating the list form, just try to bind it to the second content type (B). In my environment, this surprisingly works fine (fields from both content types are shown in the form).

Probably the point is that I have a required field in the first content type.

Anyway, even if you will not get it working, you still can do merging of the forms manually. The point is that the generated forms are represented with DataFormWebPart with some custom XSLT, so you can generate two forms for both content types, then switch to Code tabs of the forms, and then copy corresponding XSLT code from one form to the other (don't forget to change IDs of the server controls - FormField and FieldDescription, - to prevent duplicates). Also probably you will need to clear the SelectCommand attribute of the SPDataSource which is binded to your DataFormWebPart.

3
  • I am using listfielditerator in my custom form which automatically renders the fields based on content type, the requirement was for me to add jQuery sript and other modifications in the form hence the custom list definition was created. Now how do I get the content type dropdown in here? I need to show fields from content type A into add item form so that's the one which is set with item. but in edit I need them to have flexibility to switch to another content type from dropdown like you have in OOTB lists if you add multiple content types.
    – techie
    Feb 1, 2012 at 10:09
  • Your question needs to be fully rephrased and retagged then, what you're talking about is absolutely different question which relates to custom ListFieldIterator rather than to SharePoint Designer forms. Please, be specific because it turns out that I was just wasting my time answering this question :( Feb 1, 2012 at 10:17
  • I have mentioned very clearly that its with respect to custom list edit form and content type dropdown is the problem. To help everyone out I mentioned in detail what was done to create this solution and sharepoint designer 2010 is just part of it. I'm a developer myself and I would never waste my or anyone else's time. there's some misunderstanding, in which case sorry about that. Anyways, lets see if any fellow devs have faced this kind of issue. thanks
    – techie
    Feb 1, 2012 at 10:23
0
  protected void ddlContractTemplates_SelectedIndexChanged(object sender, EventArgs e)
    {
       Uri testurl=this.Request.Url;
       var qsCol = HttpUtility.ParseQueryString(Request.Url.Query);
       qsCol["ContentTypeId"] = ddlContractTemplates.SelectedValue;
      string  newUrl = testurl.Scheme + "//" + testurl.Host + ":" + testurl.Port + "/"+testurl.GetComponents(UriComponents.Path, UriFormat.SafeUnescaped) + "?" + qsCol.ToString();
       SPUtility.Redirect(newUrl,SPRedirectFlags.Default,HttpContext.Current);         }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.