2010-10-08 106 views
1

我正在使用下面的行編輯模板。我遇到的問題是當使用行編輯XSL模板時,未選擇當前值。該值默認爲列表中的第一個項目。獲取當前值作爲下面模板中選定項目的最佳方式是什麼?我認爲有DataValueField =「{@ type}」和DataTextField =「{@ type}」可以解決問題,但它不會。使用XSL和SharePoint在下拉列表中選擇當前值

<asp:DropDownList runat="server" id="ff3{$Pos}" 
DataValueField="{@type}" DataTextField="{@type}" 
__designer:bind="{ddwrt:DataBind('u',concat('ff3',$Pos),'SelectedValue','TextChanged','',string($XPath),'@type')}"> 
<asp:ListItem>1</asp:ListItem> 
<asp:ListItem>2</asp:ListItem> 
<asp:ListItem>3</asp:ListItem> 
</asp:DropDownList > 

回答

2

使用DVDropDownList代替DropDownList。請參閱this描述相同問題的MSDN論壇帖子。我在過去做過同樣的事情,並且在DVDPolownList中使用SelectedValue是我如何最終實現它的。

+0

感謝您的幫助! – 2010-10-13 13:30:38

0

試試這個:

<asp:DropDownList runat="server" id="ff3{$Pos}" 
SelectedValue="{@type}" 
__designer:bind="{ddwrt:DataBind('u',concat('ff3',$Pos),'SelectedValue','TextChanged','',string($XPath),'@type')}"> 
<asp:ListItem>1</asp:ListItem> 
<asp:ListItem>2</asp:ListItem> 
<asp:ListItem>3</asp:ListItem> 
</asp:DropDownList > 

DataValueField和DataTextField與數據結合使用,但使用的是一組特定的listItems中的。使用應該將下拉列表設置爲列表項目的當前類型值。

+0

我最初試過這個;然而,屬性'SelectedValue'不能以聲明方式設置。 – 2010-10-08 19:26:13

+0

啊...是的!現在回到我身邊(已經有一段時間了)。看到我的其他答案。我有代碼在哪裏工作。 – 2010-10-12 22:46:13

相關問題