View Single Post
  #1 (permalink)  
Old August 26th, 2010, 05:00 AM
larrydb larrydb is offline
Registered User
Join Date: Aug 2010
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default Set asp:dropdown initial SelectedValue with XSLT?

[Sorry if this isn't the right forum; my question involves both ASP and
XSLT and I wasn't sure where to post.]

I'm trying to initialize the value of a dropdown list in an XSLT
context. Simplified example: A table showing, for each channel, the
current volume and a dropdown for changing the volume. Template:

  <xsl:template name="Volume">
    <xsl:value-of select="@volume"/>
    <asp:DropDownList ... >
         <asp:ListItem Value="-1">choose volume</asp:ListItem>
         <asp:ListItem Value="0">0</asp:ListItem>
         <asp:ListItem Value="1">1</asp:ListItem>
         <asp:ListItem Value="2">2</asp:ListItem>
	 . . .
         <asp:ListItem Value="9">9</asp:ListItem>
         <asp:ListItem Value="10">10</asp:ListItem>
         <asp:ListItem Value="11">11</asp:ListItem>
(This template is used via call-template within a <table> that handles
one channel per row; irrelevant details have been suppressed.)

As it stands, the dropdown will initially show "choose volume". How can
it be made to start out showing the current @volume? One might add

<xsl:attribute name="SelectedValue"><xsl:value-of select="@volume"></xsl:attribute>
just before the first ListItem, but attribute SelectedValue "cannot be
set declaratively". Googling gives some workarounds using
SelectedValue='<%# Bind("whatever")%>' or the like but I haven't
stumbled on the right way to apply this idea in XSLT context. What's
the answer?