Solved

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

Posted on 2008-06-11
3
243 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
[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 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

691 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