D
dba56
I have a gridview inside an updatepanel. When a row is placed in edit
mode, the third editable column's control has focus. I don't know
why!!
I need the focus on the first editable column which happens to contain
a dropdownlist. So I wrote the following code:
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridView1.RowDataBound
If e.Row.RowState = (DataControlRowState.Normal Xor
DataControlRowState.Edit) OrElse _
e.Row.RowState = (DataControlRowState.Alternate Xor
DataControlRowState.Edit) Then
ScriptManager1.SetFocus(e.Row.FindControl("ddlDescription"))
End If
End sub
But on the setfocus line, I get the following error:
"SetFocus can only be called before and during PreRender."
I don't see how I can do this in the PreRender event since I don't
seem to have a way to get at the dropdownlist on the
edititemtemplate.
Can anyone shed some light on what I need to do to accomplish this?
Is there some setting in the gridview that determines the column that
gets focus when in edit mode? I've been working on it for hours,
scoured the internet and newsgroups and nothing seems to work.
Thanks in advance for any guidance.
mode, the third editable column's control has focus. I don't know
why!!
I need the focus on the first editable column which happens to contain
a dropdownlist. So I wrote the following code:
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridView1.RowDataBound
If e.Row.RowState = (DataControlRowState.Normal Xor
DataControlRowState.Edit) OrElse _
e.Row.RowState = (DataControlRowState.Alternate Xor
DataControlRowState.Edit) Then
ScriptManager1.SetFocus(e.Row.FindControl("ddlDescription"))
End If
End sub
But on the setfocus line, I get the following error:
"SetFocus can only be called before and during PreRender."
I don't see how I can do this in the PreRender event since I don't
seem to have a way to get at the dropdownlist on the
edititemtemplate.
Can anyone shed some light on what I need to do to accomplish this?
Is there some setting in the gridview that determines the column that
gets focus when in edit mode? I've been working on it for hours,
scoured the internet and newsgroups and nothing seems to work.
Thanks in advance for any guidance.