Button in Gridview Footer as DefaultButton in ASP.net Data Grid Control

Button in Gridview Footer as DefaultButton in ASP.net Data Grid Control: “Hello,

Based on my understanding, you want to define the default button in the
page so that you can insert new data by pressing enter key directly. Please
feel free to let me know if I’ve misunderstood anything.

I think you can define the property ‘DefaultButton’ in Page_Load to achieve

protected void Page_Load(object sender, EventArgs e)
form1.DefaultButton =

With this approach, button ‘AddSteamWaterData’ will be defined as the
default button in the page. Whenever the user presses the enter key, the
button will be triggered.

If you just want the default button is available when you focus on TextBox
in FooterTemplate, you can use following approach.

1. Define ‘onKeyDown’ client event to each TextBox in FooterTemplate.

<asp:TextBox ID=’NewCounter’ runat=’server’ onKeyDown=’KeyDownHandler();’

2. Use JavaScript to execute AddSteamWaterData.click when the user presses
enter key.

<script type=’text/javascript’>

function KeyDownHandler() {

// process only the Enter key
if (event.keyCode == 13) {

GridView1.FooterRow.FindControl(‘AddSteamWaterData’).UniqueID%>’, ”);


I hope this helps.


Vince Xu

Microsoft Online Support


Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s