Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4.5 > ASP.NET 4.5 General Discussion
|
ASP.NET 4.5 General Discussion For ASP.NET 4.5 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4.5 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 19th, 2013, 11:07 AM
Registered User
 
Join Date: Sep 2013
Posts: 12
Thanks: 5
Thanked 0 Times in 0 Posts
Smile Need help with buttons on Template Gridview

Hello I´m new on this forum and i got a question I´m using a Template Gridview and I put 1 buttons for make a query over one of the results in the query, and i want to know how to make the event over this buttons here is the code:

<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="btnConsultar" runat="server" CausesValidation="false"
CommandName="myLink" CommandArgument='' Text="Consultar"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>

Last edited by light882; September 19th, 2013 at 02:47 PM..
 
Old September 19th, 2013, 01:52 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

I don't understand what you're asking. Can you provide a lot more detail?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
light882 (September 19th, 2013)
 
Old September 19th, 2013, 02:37 PM
Registered User
 
Join Date: Sep 2013
Posts: 12
Thanks: 5
Thanked 0 Times in 0 Posts
Smile Hello, here is more detail

sure, well I want to make the click event over the button of :

<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="btnConsultar" runat="server" CausesValidation="false"
CommandName="myLink" CommandArgument='' Text="Consultar"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>

something like:

protected void btnConsultar_Click(object sender, EventArgs e)
{
//code of query
}

but as this button is over a gridview I don´t know how to open the event for that button, thank you a lot.
 
Old September 19th, 2013, 03:55 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

You can use the GridView's RowCommand and then test the CommandName property of the e argument for your custom CommandName setting.

More details can be found here: http://msdn.microsoft.com/en-us/libr...owcommand.aspx

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
light882 (September 19th, 2013)
 
Old September 19th, 2013, 05:45 PM
Registered User
 
Join Date: Sep 2013
Posts: 12
Thanks: 5
Thanked 0 Times in 0 Posts
Smile Thank You Very Much!

it worked thanks a lot!!!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Gridview Item Template dotnetDeveloper ASP.NET 3.5 Basics 0 February 15th, 2010 02:01 PM
Adding Properties to Buttons in a GridView Aaron Edwards ASP.NET 2.0 Basics 3 July 23rd, 2006 01:48 PM
Gridview custom buttons wirerider ASP.NET 2.0 Basics 2 February 5th, 2006 02:49 PM
Buttons in DataGrid Template Column divsalar ASP.NET 1.x and 2.0 Application Design 1 February 1st, 2005 03:37 PM
Hidden template buttons mlwallin ASP.NET 1.0 and 1.1 Basics 1 June 5th, 2003 09:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.