Solved

Add parameters to LinkButton

Posted on 2014-01-29
2
282 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

735 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