Click here to Skip to main content
11,705,610 members (47,404 online)
Rate this: bad
good
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 17: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 at 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 at 21-Nov-12 3:21am
   
Yes it is correct.. where are you stuck ?
Bhargav.456 at 21-Nov-12 4:20am
   
While I run the page, I am not getting gridview display on enter click of textbox
Bhargav.456 at 21-Nov-12 5:16am
   
I am not getting output, please help
Krunal R at 21-Nov-12 5:20am
   
write this code on TextChanged Event of TextBox
Bhargav.456 at 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
0 OriginalGriff 213
1 Sergey Alexandrovich Kryukov 160
2 Inimicos 60
3 ProgramFOX 50
4 Richard MacCutchan 45
0 OriginalGriff 9,053
1 Sergey Alexandrovich Kryukov 8,347
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,626


Advertise | Privacy | Mobile
Web02 | 2.8.150819.1 | Last Updated 21 Nov 2012
Copyright © CodeProject, 1999-2015
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