473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

datagridview and listview refresh after data getting updated

Expand|Select|Wrap|Line Numbers
  1.                 //user list view
  2.                 da = new SqlDataAdapter("SELECT * FROM [user]", con);
  3.                 DataTable t = new DataTable();
  4.                 ds = new DataSet();
  5.                 da.Fill(ds);
  6.                  t = ds.Tables[0];
  7.                 listView1.View = View.Details;
  8.                 for (int i = 0; i < t.Rows.Count; i++)
  9.                 {
  10.                     DataRow dr= t.Rows[i];
  11.                     ListViewItem item = new ListViewItem(dr["id"].ToString());
  12.                     //item.Text = dr ["id"].ToString();        
  13.                     item.SubItems.Add(dr["name"].ToString());
  14.                     item.SubItems.Add(dr["uname"].ToString());
  15.                     item.SubItems.Add(dr["profession"].ToString());
  16.                     listView1.Items.Add(item);
  17.                     //listView1.Items.Add(dr[0].ToString()).SubItems.Add(dr[1].ToString());
  18.                     con.Close();
  19.  
  20.                 }
  21.                 //data grid view user inssert or delete
  22.                 con.Open();
  23.                 da = new SqlDataAdapter("SELECT * FROM [user]", con);
  24.                 DataTable t1 = new DataTable();
  25.                 da.Fill(t1);
  26.                 dataGridView1.DataSource = t1;
  27.                 con.Close();
  28.  

i tried with datagridview.refresh, update but its not working can any body sugesst me what to do for refresing the data ....do timer we have to use..? if yes then how ...?
in advanced thanks
Jan 9 '13 #1
6 10837
adriancs
122 100+
maybe somewhere else is resetting the datagridview.
Jan 14 '13 #2
@adriancs where that resetting boss....dat only i want .?
Jan 15 '13 #3
adriancs
122 100+
assume that table "user" has rows...
I am 100% sure that this code is working with no error.
Expand|Select|Wrap|Line Numbers
  1. con.Open();
  2. da = new SqlDataAdapter("SELECT * FROM [user]", con);
  3. DataTable t1 = new DataTable();
  4. da.Fill(t1);
  5. dataGridView1.DataSource = t1;
  6. con.Close();
You can try to create another form and build only a datagridview.
and prove it.

therefore, there is something wrong with your other code which is not shown in your 1st post.
Jan 15 '13 #4
this is working boss... but its not getting refresh when update or insert done.....
Jan 16 '13 #5
adriancs
122 100+
hi boss, manually update it?
Expand|Select|Wrap|Line Numbers
  1. public void UpdateGridView()
  2. {
  3.     con.Open();
  4.     da = new SqlDataAdapter("SELECT * FROM [user]", con);
  5.     DataTable t1 = new DataTable();
  6.     da.Fill(t1);
  7.     dataGridView1.DataSource = t1;
  8.     con.Close();
  9. }
Expand|Select|Wrap|Line Numbers
  1. public void UpdateData()
  2. {
  3.     // Do something Update
  4.     UpdateGridView();
  5. }
Expand|Select|Wrap|Line Numbers
  1. public void InsertData()
  2. {
  3.     // Do something Insert
  4.     UpdateGridView();
  5. }
Jan 16 '13 #6
@adriancs thanks for this idea boss i think it will work ........
Jan 23 '13 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Mountain Man | last post by:
Hi, I posted on this matter earlier with the subject line "Trouble with sessions," but someone else started a different thread with the same subject line that arrived before my post, so I'm...
0
by: Ana RM | last post by:
Hi everybody, I have a problem in Discoverer. The point is that I don´t want to refresh data each time I open a workbook. I want to mantain old reports. If I open a report without connecting...
1
by: Aleksandar Andjelkovic | last post by:
Greetings, Is there a way in ASP.NET to refresh data grid control without (post back) reload of the hole page Thank you, Aleksandar
0
by: Anil Kumar Lakky Reddy | last post by:
I have seen lots of people complaining about not getting updated values from edit columns of datagrid. I had similar problem, I figured I was refreshing the data on each page load. I fixed it by...
4
by: Hardik Shah | last post by:
Hi, I have a combobox for city name help , which uses dataset as datasource , when other user from network add any other city or edit city, it is not reflect in my current form (in run mode) ,...
2
by: Rick Shaw | last post by:
Hi, I have a problem with the datagridview not refreshed when the application first appear on the screen. The datagridview display data from a table in the dataset. At the same time, I've added...
3
by: RichT | last post by:
Hi all, I am experiencing some odd behaviour with a DataGridView. The DataGridView is bound to a DataTable, which is populated with data from a csv file. The column Headings appear fine,...
0
Boxcar74
by: Boxcar74 | last post by:
Hi Everybody!!! I have an Issue. I have an Excel file that queries an Access db. I’m trying to have it so I don’t have to keep updating it manually everyday and save it to a network drive...
0
by: girishpatil | last post by:
how to modify listview subitems data manually.listview is filled with data from datab
2
by: Sridhar G | last post by:
I am new to VBA and have very minimum knowledge on it. I have a form with data (records) loaded and when you double click any record in the form, one edit form will be opened where you can edit the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.