View Single Post
  #6 (permalink)  
Old August 26th, 2010, 08:45 AM
samjudson's Avatar
samjudson samjudson is offline
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Apologies, you're right - I got confused and though I was the XSLT forum again (which to be fair I mostly am).

I think you need to output XML like this:

Code:
    <asp:DropDownList runat="server" ID="DropDownList1">
        <asp:ListItem Value="1">1</asp:ListItem>
        <asp:ListItem Value="2" Selected="True">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:DropDownList>
The question is how best to do this easily and cleanly.

If this was XSLT 2 then you could do a simple loop on the range, but as I suspect you are probably in XSLT 1 then it will probably just have to be a check after each list item:

Code:
  ...
  <asp:ListItem Value="1"><xsl:if test="@volume=1"><xsl:attribute name="Selected">True</xsl:attribute>1</xsl:if></asp:ListItem>

  <asp:ListItem Value="2"><xsl:if test="@volume=2"><xsl:attribute name="Selected">True</xsl:attribute>2</xsl:if></asp:ListItem>
  ...
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
The Following User Says Thank You to samjudson For This Useful Post:
larrydb (August 26th, 2010)