Solved

VB ASP.NET GridView Edit

Posted on 2010-11-23
6
319 Views
Last Modified: 2012-05-10
I am using VS 2008 VB.net...  I have an aspx page with a gridview on it.

The issue I am having is when you select the "Edit" button, the page does a Post Back to change to Edit mode. and the Starts out at the top of the screen again. So you have to scroll down to find the Row you want to edit again.

How can I set the focus to the first textbox of the row being edited?

Thanks

0
Comment
Question by:Wildone63
  • 3
  • 2
6 Comments
 
LVL 13

Expert Comment

by:Jesus Rodriguez
ID: 34198411
On the RowCommand event, verify the event and if is Edit then set the focus to the control
0
 
LVL 1

Author Comment

by:Wildone63
ID: 34198601
How do I set focus to the control?
Can you give me an example please?

Thank You.
0
 
LVL 13

Accepted Solution

by:
Jesus Rodriguez earned 500 total points
ID: 34198991
try this

 Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow AndAlso (e.Row.RowState And DataControlRowState.Edit) <> 0 Then
            Dim c As Control = e.Row.Cells(2).Controls(0)
            Me.SetFocus(c)
        End If

    End Sub
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 13

Expert Comment

by:Jesus Rodriguez
ID: 34199208
Also you can do this, set it programmatically

Page.MaintainScrollPositionOnPostBack = true
In the page declaration

<%@ Page MaintainScrollPositionOnPostback="true" %>
Or in the web.configs <system.web> section.

<pages maintainScrollPositionOnPostBack="true" />
This feature is an absolute must-have on large web pages built for postback scenarios.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34199884
0
 
LVL 1

Author Closing Comment

by:Wildone63
ID: 34200197
Thank You.
This worked perfectly!
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

803 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