Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2008-06-11
3
Medium Priority
?
254 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 1000 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

609 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