Solved

How to maintain selected row in a datagridview after reselecting data from Database?

Posted on 2008-06-11
3
230 Views
Last Modified: 2013-11-26
I am using a datagridview in c# application. After selecting one row and making some changes to it I need to reload all data from Database but the problem is that the selected row will be lost and it always go to the first row. What's the best way of retaining the prosition of selecte row after reloading the data.
0
Comment
Question by:Elham_Seif
3 Comments
 
LVL 16

Expert Comment

by:burakiewicz
ID: 21761671
you could store the rowNumber in session,hiddenField or viewstate
0
 
LVL 14

Accepted Solution

by:
Daniel Junges earned 250 total points
ID: 21761751

// Strore the index
int index = dataGridView1.CurrentRow.Index;
...
// Select the same index again
if(dataGridView1.Rows.Count < index + 1)
  dataGridView1.Rows[index].Selected = true;
0
 

Author Comment

by:Elham_Seif
ID: 21761827
thanks
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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 …
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 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

9 Experts available now in Live!

Get 1:1 Help Now