MSDN > 論壇首頁 > SharePoint - Design and Customization > Passing parameters from a dataview via querystring
發問發問
 

已答覆Passing parameters from a dataview via querystring

  • Friday, 3 July, 2009 21:24prostration 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    I have a dataview that displays the items from a list. I inserted a column and added a hyperlink, from there I added whatever parameters I wanted to pass, this works great. Now how can I do this with a button instead of a hyperlink? I tried to do it by adding a button instead of a hyperlink to my new column and placing this code inside my button: document.location.href = ('http://something/something.aspx' + <xsl:value-of select="@whateverparameteriwanttopass"/>)

    However instead of getting the specific value for the parameter of the row where I click the button like it does with the hyperlink, it always gives me the value of the last item in the dataview. How can I fix this?

解答

  • Friday, 3 July, 2009 21:56Mchova01 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     已答覆

    Try replaing the code to create your button with the following:

    <INPUT TYPE="BUTTON" VALUE="Button Title" ONCLICK="window.location.href='http://something/something.aspx?ID={@ID}'"/>

    Replace "?ID=" with the name of your parameter, (e.g. "?Myparameter=")
    Replace {@ID} with the column name used for the parameter source (e.g. {whateverparameteriwanttopass})

    This worked on my end.

所有回覆