Is there a good reference SharePoint's databinding syntax?
Asked Answered
E

1

6

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">
   <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?

Edmon answered 31/8, 2009 at 15:34 Comment(1)
This question is now a tumbleweed. I'm going to have start researching this myself.Edmon
E
6

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

Edmon answered 23/9, 2009 at 13:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.