Passing variables through non HTML object

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mbewers1
    New Member
    • Feb 2009
    • 68

    Passing variables through non HTML object

    Hi there,

    I'll try and explain this as best as I can.
    I have a search page which generates a GridView of results based on the search terms entered by the user.

    One of the columns in GridView is called a DOI (Document Object Itentifier).
    This DOI is used to find academic papers through http://dx.doi.org/ when a user enters a DOI string.

    What I would like to do is redirect the user to the relevant webpage when they have selected the DOI in the GridView, however, the url for this page is always different.

    In the page, I have formatted the form tag like so:
    Code:
    <form method="post" id="form1" action="http://dx.doi.org" runat="server">
    and in my GridView, I have formatted the row that I wish to have hyperlinked like so:
    Code:
    <asp:ButtonField DataTextField="DOI" HeaderText="DOI" CommandName="d"/>
    Then, in my C# codebehind, I have the following event which aims to redirect the user to the required page, based on the tag they have selected:
    Code:
    switch (e.CommandName)
            {
                case "d":
                    searchResult.Attributes.Add("onchange", "window.open('http://dx.doi.org' + this.value);");
                    break;
            }
    I don't think this code above makes any difference though as the form tag is already specifying the redirected url, nor do I think this task can be done with a html <table> object, as it only accepts static data, rather than a result set generated from a database, which is what I'm doing.

    I have also looked at the following post as a guide to this type of problem but, taking account of what it said didn't allow me to solve this problem completely.


    Is all the above clear and understandable?
    If so, is what I am asking possible.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Have you considered using a Hyperlink?

    What I'm thinking is that you could use a TemplateField that contains a hyperlink. You would generate the link by using concatenating it to the bound DOI value.

    Something like:
    Code:
    <asp:GridView id="theGrid" runat="server" AutoGenerateColumns="false">
      <Columns>
        <asp:TemplateField>
          <ItemTemplate>
              <a href="#" onclick="window.open('http://dx.doi.org?doi=<#Eval('DOI')%>);"><#Eval('DOI')%></a>
          <ItemTemplate>
        </asp:TemplateField>   
      </Columns>
    </asp:GridView>
    -Frinny

    Comment

    Working...