Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB ASP.NET GridView Edit

Posted on 2010-11-23
6
Medium Priority
?
327 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

722 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