Solved

VB ASP.NET GridView Edit

Posted on 2010-11-23
6
316 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 13

Expert Comment

by:Jesus Rodriguez
Comment Utility
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
Comment Utility
0
 
LVL 1

Author Closing Comment

by:Wildone63
Comment Utility
Thank You.
This worked perfectly!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now