Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 470301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:52:17+00:00 2026-05-12T23:52:17+00:00

1) If we first set DropDownList.SelectedIndex to some value and then rebind control to

  • 0

1) If we first set DropDownList.SelectedIndex to some value and then rebind control to data source, it’s SelectedIndex property will be reset to default. So why doesn’t something similar happen with GridView.SelectedIndex and GridView.EditIndex? It seems that unlike DropDownList, GridView doesn’t reset these two properties ( to their default values ) after a re-bind.

2)

If you set the GridView.EditIndex property after a postback or in handlers for events that are raised later than the Load event, the GridView control might not enter edit mode for the specified row. If you read the value of this property in other event handlers, the index is not guaranteed to reflect the row that is being edited.

Why could setting GridView.EditIndex after postback or in handlers raised after Load event cause GridView not to enter into Edit mode?

thank you

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T23:52:17+00:00Added an answer on May 12, 2026 at 11:52 pm

    In order for a GridView row to be in edit mode, the grid must be databound. So resetting EditIndex wouldn’t make much sense. As for SelectedIndex… I imagine that is just simply a design decision.

    As for number two… I think this text is misleading. Does it come from MSDN? I think what it is trying to say is “don’t do this or allow it to happen:”

    some EventHandler {
        grid.EditIndex = X;
        grid.DataBind();
        grid.EditIndex = Y;
    }
    

    You see? What row are we editing now?

    [Edit]

    This has everything to do with Question 2. You see, with the above code we are actually still editing row X. (but most likely, you will get a state error when you go to postback). Setting EditIndex itself does not put the GridView into edit mode… so your question is somewhat moot to begin with. What actually puts a row in edit mode is having this property set when the grid is databound. EditIndex really just tells the Render method which template to use: ItemTemplate or EditTemplate.

    Like I said before, I believe the text you quoted is misleading. The important thing is knowing when the data binding happens. The text you quoted seems to assume that that is happening during Load.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, a little background: I'm displaying a data set with 288 rows and 8
I'm having some doubts on how to set up my SVN stuff. First my
I need to set/get the cookies stored at first.example while browsing second.example , I
I've always taken the approach of first deploying the database with a minimal set
NOTE: I am not set on using VI, it is just the first thing
I'll go first. I'm 100% in the set-operations camp. But what happens when the
First, let's get the security considerations out of the way. I'm using simple authentication
First off, I am using Windows XP. I have multiple hard drives and it
First off, I understand the reasons why an interface or abstract class (in the
First off if you're unaware, samba or smb == Windows file sharing, \\computer\share etc.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.