0
votes

I'm customizing a custom list form in xslt using SharePoint designer. In my list, I have a textbox that represents a numerical value.

I would like to present this textbox to the user as a dropdown list with pre-defined values (1-7). Unfortunately, I can't use a SPFieldChoice because it is evaluated as a string in my SharePoint Designer Workflow and there aren't any built-in conversions.

I'm hoping that I could simply define an asp DropDownList control and use the ddwrt:DataBind syntax, but the following isn't working.

<asp:DropDownList id="ddlValue" runat="server" 
   __designer:bind="{ddwrt:DataBind('i', 'ddlValue', 
                    'SelectedValue', 'OnSelectedIndexChanged', 'ID',
                     ddwrt:EscapeDelims(string(@ID)),'@MyField')}">
   <asp:ListItem value="1" selected="true">1</asp:ListItem>
   <asp:ListItem value="2">2</asp:ListItem>
   <asp:ListItem value="3">3</asp:ListItem>
   <asp:ListItem value="4">4</asp:ListItem>
   <asp:ListItem value="5">5</asp:ListItem>
   <asp:ListItem value="6">6</asp:ListItem>
   <asp:ListItem value="7">7</asp:ListItem>    
</asp:DropDownList>

The selected value "1" does get saved with the item when it's created, so it is picking up the databinding. However, if I select any other value, it still records "1".

Is the syntax wrong, or is there a better way?

What would you do?

2
@bryanbcook: Please tag with sharepoint as well as the others when asking questions. Some SharePoint-ers monitor this tag only so you will catch a wider audience.Alex Angas

2 Answers

0
votes

Looks like my binding syntax is wrong. Changing it to use the TextChanged event instead of OnSelectedIndexChanged.

The following appears to work:

 __designer:bind="{ddwrt:DataBind('i', 'ddlValue',
                   'SelectedValue, 'TextChanged', 'ID'
                   ddwrt:EscapeDelims(string(@ID), '@MyField')}"
0
votes

workaround: try a pre-selection parameter

<xsl:param name="Anrede" select="@Anrede"/>

and use it in

<asp:DropDownList runat="server" id="ff1{$Pos}" 
__designer:bind="{ddwrt:DataBind('u',concat('ff1',$Pos),'SelectedValue', 'TextChanged','ID',ddwrt:EscapeDelims(string('')),'@Anrede')}" >
    <asp:ListItem value="{$Anrede}" selected="true"><xsl:value-of select="@Anrede"></xsl:value-of></asp:ListItem>                   
    <asp:ListItem value="">----</asp:ListItem>
    <asp:ListItem value="Herr">Herr</asp:ListItem>
    <asp:ListItem value="Frau">Frau</asp:ListItem>
</asp:DropDownList>