Click here to Skip to main content
12,239,997 members (63,817 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
Hello, I have a textbox and a gridview.

Initially the gridview was hidden, I used modal popup extender to display gridview on textbox click.

On textbox mouse click, I will get the gridview displayed.

Now, what I need is to display the gridview on ENTER Click (i.e., from keyboard) in the textbox and not with any other. Can anyone help?

Thanks.
Posted 20-Nov-12 18:56pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

private void TextBox_KeyDown(object sender, KeyEventArgs e)
       {
           if (e.KeyCode == Keys.Enter)
           {
               DataGridView1.Visible = true;
           }
       }
  Permalink  
Comments
Bhargav.456 21-Nov-12 3:17am
   
Thanks, but I am not getting output. I have written like this.

design:
<asp:TextBox ID="TextBox1" runat="server" OnKeyDown="TextBox1_KeyDown()"
AutoPostBack="True">
in cs:

private void TextBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
GridView1.Visible = true;
}
}

is it correct?
Krunal R 21-Nov-12 3:21am
   
Yes it is correct.. where are you stuck ?
Bhargav.456 21-Nov-12 4:20am
   
While I run the page, I am not getting gridview display on enter click of textbox
Bhargav.456 21-Nov-12 5:16am
   
I am not getting output, please help
Krunal R 21-Nov-12 5:20am
   
write this code on TextChanged Event of TextBox
Bhargav.456 21-Nov-12 5:50am
   
Sorry,

I am getting this error after writing code in textbox changed event.

CS1061: 'System.EventArgs' does not contain a definition for 'KeyCode' and no extension method 'KeyCode' accepting a first argument of type 'System.EventArgs' could be found (are you missing a using directive or an assembly reference?)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 21 Nov 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100