如何将 SharePoint 文本字段绑定到下拉列表?
我正在使用 SharePoint 设计器在 xslt 中自定义自定义列表表单。在我的列表中,我有一个代表数值的文本框。
我想将此文本框作为带有预定义值 (1-7) 的下拉列表呈现给用户。不幸的是,我无法使用 SPFieldChoice,因为它在我的 SharePoint Designer 工作流中被评估为字符串,并且没有任何内置转换。
我希望我可以简单地定义一个 asp DropDownList 控件并使用 ddwrt:DataBind 语法,但以下内容不起作用。
<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>
所选值“1”在创建时会与项目一起保存,因此它会获取数据绑定。但是,如果我选择任何其他值,它仍然记录“1”。
是语法错误还是有更好的方法?
你会怎么办?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来我的绑定语法是错误的。将其更改为使用 TextChanged 事件而不是 OnSelectedIndexChanged。
以下似乎有效:
Looks like my binding syntax is wrong. Changing it to use the TextChanged event instead of OnSelectedIndexChanged.
The following appears to work:
解决方法:
尝试预选参数
并将其用于
workaround:
try a pre-selection parameter
and use it in