Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Add parameters to LinkButton

Posted on 2014-01-29
2
Medium Priority
?
295 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:
Hiran Desai earned 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Integration Management Part 2
Loops Section Overview
Suggested Courses

963 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