?
Solved

Save records by hitting a enter key

Posted on 2006-05-15
3
Medium Priority
?
161 Views
Last Modified: 2008-03-17
the "Enter" key.
I have textboxes( item template)  inside of a gridview  and a form view

((TextBox)row.Cells[11].FindControl("TextBox2")).Text;

The use can enter a number inside of the textbox and click save all button to be able to save the records that they just entered.

I was using below code to be able to achive the goal.
Here is the code

 function doFocus(key)
{
    if(key == 13) document.getElementById('Button2').focus();
}
 
 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        ((TextBox)e.Row.Cells[11].FindControl("TextBox2")).Attributes.Add("onkeydown", "doFocus(window.event.keyCode);");
    }
}


the functionally of this coce is when the user press the enter key in the textbox then set the focus to the save button... it's like the user do click on the button.

but I am getting an error says: ArgumentOutofRangeException was unhandled by user code. Specified argument ws out of the range of valid values" I made sure that Textbox2 is Cells[11]...

wha I am doing wrong here??
0
Comment
Question by:jung1975
1 Comment
 
LVL 27

Accepted Solution

by:
Sammy earned 2000 total points
ID: 16685066
try this in your page_load
Textbox2.Attributes.Add("onkeydown", "doFocus(window.event.keyCode);");
if this doesnt work, use findcontrol and attach the client script event

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question