Link Button from a detailsview

Posted on 2009-02-10
Last Modified: 2013-12-17
I have a detailsview that displays details of jobs that are live on our DB.  The problem I stuck with is passing a link button a jobid as querystring to open on another page.  I know this is possible because use the same typ of thing.  Can some please point in the right direction??

Question by:leap29
    LVL 41

    Accepted Solution

    Here is the basic idea:
    Note that LinkButton is a normal button with look and feel like a Hyperlink Button but it is not HyperLink button.
    So you can set the commandArgument of Link button to your jobid and do something like below:

    <asp:LinkButton ID="LinkButton1" CommandName="DetailsViewRedirect" runat="server" CommandArgument='<% Eval("JobId") %>' oncommand="LinkButton1_Command">LinkButton</asp:LinkButton>
    code behind:
     protected void LinkButton1_Command(object sender, CommandEventArgs e)
            if (e.CommandName == "DetailsViewRedirect")
                Response.Redirect("yourRedirectUrl?jobid=" + e.CommandArgument);

    Open in new window


    Author Comment

    Hi, thankyou for your response. I have tried it and am coming up with the following error.
    Conversion failed when converting the nvarchar value '<% Eval("JobId") %>' to data type int.
     Is there a way around this?
    Many thanks

    Author Comment

    doesnt matter i solved the problem myself.
    i was missing a #
    actual code was
    <asp:LinkButton ID="LinkButton1" CommandName="DetailsViewRedirect" runat="server" CommandArgument='<%# Bind("jobid") %>' oncommand="LinkButton1_Command">more</asp:LinkButton>
    thanks for your help.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now