SharePoint:FormField in a custom webpart? -


on home page, want simple webpart allow users fill entry in list.

the list have, let's say, 3 fields : title (text), body (rich text), category (lookup).

i don't want use standard dataformwebpart because have bit of code-behind fill technical hidden fields of list (actually, don't exclude dataformwebpart, didn't find how use code behind).

so started implement custom webpart. because don't want have handle manually each field input, started use formfield control, automatically choose rendering control, , provide value property correct format :

<sharepoint:formfield runat="server" id="fldtitle" fieldname="title" /> 

this code not sufficient, have specified listid :

<sharepoint:formfield runat="server" id="fldtitle" fieldname="title" listid="{title list guid}" /> 

this working quite correctly. can in code access fldtitle.value retrieve user input.

but have include webpart in packaged , deployed feature, can activated. webpart target same list, list instanciated in feature (listinstance element), can't know guid in advance.

i've tried using several technics set list id on fly, without success.

i've "reflectored" sp dlls notice formcomponent class using "context" set listformwebpart.

finally, questions :

  • is correct way create custom input webpart on home page (not list custom form) ?
  • how can keep behavior of formfield (choose right control , handle input , conversion storage format) ?
  • will have create custom listformwebpart ?
  • may play controltemplates ?

thanks in advance help... i'm struggling simple case days now...

i think customizing form templates easiest way customize list forms. since custom form templates implemented user controls can add whatever code want. see following article: http://www.codeproject.com/kb/sharepoint/sharepointlistforms.aspx


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -