Click here to Skip to main content
15,907,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

1 solution

C#
private void TextBox_KeyDown(object sender, KeyEventArgs e)
       {
           if (e.KeyCode == Keys.Enter)
           {
               DataGridView1.Visible = true;
           }
       }
 
Share this answer
 
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?
[no name] 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
[no name] 21-Nov-12 5:20am    
write this code on TextChanged Event of TextBox

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900