views:

46

answers:

2

I'm using the row edit template below. The problem I have is that the current value is not selected when the row edit XSL template is used. The value defaults to the first item in the list. What is the best way to get the current value to be the selected item in the template below? I thought having DataValueField="{@type}" and DataTextField="{@type}" would resolve the issue, but it does not.

<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 > 
A: 

Try this:

<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 and DataTextField are used with data binding, but you are using a specific set of ListItems. Using SelectedValue should set the drop down list to the List Item's current value of type.

Rich Bennema
I tried initially this; however, the property 'SelectedValue' cannot be set declaratively.
Jon.ee
Ah... yes! It's coming back to me now (it's been awhile). See my other answer. I have code where that one is working.
Rich Bennema
+2  A: 

Use DVDropDownList instead of DropDownList. See this MSDN forum post describing the same problem. I've done the same thing in the past and using SelectedValue with DVDropDownList is how I finally got it to work.

Rich Bennema
Thanks for the help on this!
Jon.ee