Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB ASP.NET GridView Edit

Posted on 2010-11-23
6
Medium Priority
?
328 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 2000 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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Loops Section Overview
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

927 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