Had a customer ask for this functionality. Easily done. I can see using it in most of my GridView applications. You could modify this to recursively move throught e.Controls and find the first TextBox.
protected void GridViewMain_RowDataBound(object sender, GridViewRowEventArgs e) {
if (e.Row.RowIndex == GridViewMain.EditIndex && e.Row.RowIndex != -1) {
const string selectScript = "<script language='javascript'>document.getElementById('{0}').select();</script>";
Control control = e.Row.FindControl("TextBoxQuantity");
if (control != null) {
Page.ClientScript.RegisterStartupScript(this.GetType(), "FocusEditTextBox", string.Format(selectScript, control.ClientID));
}
Remember Me
a@href@title, strike
Powered by: newtelligence dasBlog 2.0.7226.0
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2008, Andrew Robinson
E-mail