?
Solved

HyperLinkField vs Button

Posted on 2006-03-28
3
Medium Priority
?
567 Views
Last Modified: 2012-08-14
How do I make

<asp:HyperLinkField Text="Select" DataNavigateUrlFields="nPDID"
  DataNavigateUrlFormatString="DetailsViewEdit.aspx?ID={0}" />    

look like

<asp:TemplateField ItemStyle-VerticalAlign="Top">
  <ItemTemplate>
    <asp:Button ID="gvSelectButton" CommandName="Select" Text="Select" Runat="Server" />
  </ItemTemplate>
</asp:TemplateField>  

or how to make a button that will call the same thing as the hyperlink field.

thanx
0
Comment
Question by:heincpa
3 Comments
 
LVL 4

Expert Comment

by:pbocanegra
ID: 16315609
the button is a server controls and triggered events. Usually, the hyperlink is a pointer to another place.
0
 
LVL 22

Accepted Solution

by:
Jason Scolaro earned 500 total points
ID: 16316267
Within your GridView's RowCommand event you can have code like the following:

If e.CommandName = "Select" Then
  Response.Redirect("DetailsViewEdit.aspx?ID=" & CStr(e.CommandArgument))
End If

You'll have to set the CommandArgument field on your Button, something like:
<asp:Button ID="gvSelectButton" CommandName="Select" CommandArgument='<%# Eval("nPDID") %>'Text="Select" Runat="Server" />

Good luck!
-- Jason
0
 
LVL 1

Author Comment

by:heincpa
ID: 16317802
Awesome...

and because I hate it when people just say thanx and don't post the final solution:

aspx page

                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:Button CommandName="Select" CommandArgument='<%# Eval("nPDID") %>' Text="Select" runat="server"/>
                    </ItemTemplate>
                </asp:TemplateField>

code behind:

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Select")
        {

            Response.Redirect("DetailsViewEdit.aspx?ID=" + e.CommandArgument.ToString());
        }

    }

had to use tostring instead of CStr - VB vs C#

Thanx a bunch!
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question