Using ajax with gridview and cannot set focus in edit mode

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top