Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 398
  • Last Modified:

Link Button from a detailsview

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 totaljobs.com use the same typ of thing.  Can some please point in the right direction??

0
leap29
Asked:
leap29
  • 2
1 Solution
 
guru_samiCommented:
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

0
 
leap29Author Commented:
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
0
 
leap29Author Commented:
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.
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now