Solved

Add parameters to LinkButton

Posted on 2014-01-29
2
278 Views
Last Modified: 2014-01-29
Might not even be doing this correctly so I'll explain what I'm trying to do. Very simply I'm trying to create a GridView and within this I will have a button. This button will have some additional parameters added to it (namely an ID) so I would suspect it would look something like #/volunteer.aspx?ID=000000 (with the actual ID added to the end of the link)

So I have my code like this:
<asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:LinkButton runat="server" ID="NewViewReports" CommandName="ViewReports" CommandArgument='<%# Eval("CRM_BusinessGUID", "~/Volunteer.aspx?ID={0}") %>' CssClass="btn btn-primary btn-large" Text="New View Reports &raquo;" />
                                    </ItemTemplate>
                                </asp:TemplateField

Open in new window

and although the button is created correctly the links are not there but the HTML looks like this:
<a class="btn btn-primary btn-large" id="MainContent_ctl00_GridView1_NewViewReports_0" href="javascript:__doPostBack('ctl00$MainContent$ctl00$GridView1$ctl02$NewViewReports','')">New View Reports »</a>

Open in new window

Hopefully this is an easy one to sort and I've explained what I'm after so appreciate any advice you guys can offer.

Thanx again
0
Comment
Question by:Steven O'Neill
2 Comments
 
LVL 4

Accepted Solution

by:
ItWorked earned 500 total points
ID: 39817627
The reason is you have placed the LinkButton in GridView and the URL that you have plaved is as CommandArgument.

If you need to have just a redirect then you can put the same code for
NavigationURL

Open in new window


If you want to work otherway,
 you need to handle RowCommandEvent of GridView. Where you'll check commandname by e.CommandName=="ViewReports"
and redirect to page by using
e.CommandArgument

Open in new window


Hope this will help
0
 
LVL 2

Author Closing Comment

by:Steven O'Neill
ID: 39817681
Ok being very thick here lol...that's sorted my issue but should've known that one.

Ended up using the NavigateUrl method

Thanx again
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

777 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