views:

1090

answers:

1

I'm putting asp server-controls into my SharePoint XSLT using SharePoint Designer. I've found it's really handy for pre-populating values into the form, or providing a different experience than the SharePoint defined layout (hidden fields, etc).

For example, I can use a asp:TextBox control instead of the SharePoint:FormField control if I define it as such:

<xsl:stylesheet ... xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"&gt;
   <xsl:param name="Name" />

   <xsl:template match="/">
       <!-- omitted for clarity -->

       <asp:TextBox id="txtName" runat="server" Text="{$Name}"
         __designer:bind="{ddwrt:DataBind('i','txtName','Text','TextChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@MySharePointField')}"

   </xsl:template>
</xsl:stylesheet>

I've googled but can't seem to find a good reference for the parameters for ddwrt:DataBind method.

Does anybody know?

+2  A: 

The ddwrt:DataBind method is a wrapper for DataFormWebPart.AddDataBinding

The mysterious first parameter refers to the "operation". It will either be "i" (insert), "u" (update), or "d" (delete). Sadly, these are literal values because the XSLT doesn't have access to enumerations, etc.

The other curious fields are the propertyName and eventName, which are members of the control you're binding. The event is wired up using reflection to the sharepoint form, and the property is used to retrieve the value.

The remaining fields refer to the primary key and value to bind.

Full details on the method signature and how to use it can be found here

bryanbcook