Solved

VB ASP.NET GridView Edit

Posted on 2010-11-23
6
323 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
looking for an ASP.net report designer 4 41
Access Schema 6 45
ModalPopup  question 22 37
Powershell form - Anchor a button to a dynamically sized groupbox 2 41
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

685 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