Switch last gridview row to EditMode

Posted on 2010-01-06
Last Modified: 2012-08-14
I have code to insert a row into a gridview bound by a SqlDataSource and it prepopulates values.  How do I reference the inserted row (the last row of the gridview) and then switch that row to EditMode?

GridView1 is the name

Using VS2008Team, ASP.NET 3.5, SQL Server 2008 Ent

Thanks in advance!
Question by:cdX
    LVL 11

    Accepted Solution

    LVL 3

    Assisted Solution

    set the edit index of gridview to newly inserted row before rebinding it to datasource,

    this.GridView1.EditIndex = NewRowIndex;
    //Databind code here

    Author Comment

    I used a combination of both of your comments to come up with the solution.  Thanks!
    --INSERT COMMAND Code here--
    Dim LastRowIndx As Integer
    LastRowIndx = GridView1.Rows.Count - 1
    GridView1.EditIndex = LastRowIndx

    Open in new window


    Author Closing Comment

    The fact that I asked two questions actually, and one was solved for each.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    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…
    In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    734 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

    21 Experts available now in Live!

    Get 1:1 Help Now