Click here to Skip to main content
Rate this: bad
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?
Posted 20-Nov-12 17:56pm

1 solution

Rate this: bad
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;
Bhargav.456 at 21-Nov-12 3:17am
Thanks, but I am not getting output. I have written like this.
<asp:TextBox ID="TextBox1" runat="server" OnKeyDown="TextBox1_KeyDown()"
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
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 400
1 Gihan Liyanage 238
2 Sergey Alexandrovich Kryukov 150
3 ChauhanAjay 120
4 syed shanu 110
0 Sergey Alexandrovich Kryukov 9,021
1 OriginalGriff 7,941
2 CPallini 2,603
3 Richard MacCutchan 2,121
4 Abhinav S 1,928

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