Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
Run mode screen in datagridview as follows; Load(Button)
 
i have one button called Load.
 
Date Session NR PN GS

28-Jan 1 REO PH2 TASCO
28-Jan 2
28-Jan 3
28-Jan 4
29-Jan 1
29-Jan 2 AFF MFA CTF
29-Jan 3
29-Jan 4
30-Jan 1
30-Jan 2
30-Jan 3 TFC LGTF ECDIS
30-Jan 4
31-Jan 1
31-Jan 2
31-Jan 3
31-Jan 4 ERSM ARPA REO
1-Feb 1 PH2 TASCO AFF
1-Feb 2
1-Feb 3
1-Feb 4
2-Feb 1
2-Feb 2 MFA CTF TFC
2-Feb 3
2-Feb 4
 
all the above details are entered in the datagridview and save it in the database.
it is working fine no problem.
 

then i switch off my system today.
 
Next day i open my project and run this screen.
when i click the Load button all the data's i entered in the datagridview in the previous day that data's to be shown in the datagridview.
 

for that how can i write the code.please help me.
 
Database Design as follows;
 
Sch_Date Date/Time
Session Number
course Text
Faculty_Code Text
 
Tablename Schedule.
 
in the schedule table all the details are saved in the database.
 
when i click the load button output as follows;
 
Date Session NR PN GS

28-Jan 1 REO PH2 TASCO
28-Jan 2
28-Jan 3
28-Jan 4
29-Jan 1
29-Jan 2 AFF MFA CTF
29-Jan 3
29-Jan 4
30-Jan 1
30-Jan 2
30-Jan 3 TFC LGTF ECDIS
30-Jan 4
31-Jan 1
31-Jan 2
31-Jan 3
31-Jan 4 ERSM ARPA REO
1-Feb 1 PH2 TASCO AFF
1-Feb 2
1-Feb 3
1-Feb 4
2-Feb 1
2-Feb 2 MFA CTF TFC
2-Feb 3
2-Feb 4
 

how can i do?how can i write the code.please help me.
 
Thanks & Rgds,
Narasiman P
Posted 30-Jan-13 2:53am
Comments
SChristmas at 30-Jan-13 7:56am
   
Are you asking how to bind the datagrid on the click of load button?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try below code on click of Load button
 
string query = "SELECT * FROM Person";
        SqlDataAdapter da = new SqlDataAdapter(query, connection);
        SqlCommandBuilder cb = new SqlCommandBuilder(da);
        DataTable dt = new DataTable();
        da.Fill(dt);
        BindingSource bs = new BindingSource();
        bs.DataSource = dt;
        dataGridView1.DataSource = bs;
  Permalink  
Comments
Espen Harlinn at 30-Jan-13 8:10am
   
5'ed! :-D
SChristmas at 30-Jan-13 8:17am
   
thanks :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 DamithSL 320
1 OriginalGriff 235
2 Afzaal Ahmad Zeeshan 154
3 Sergey Alexandrovich Kryukov 147
4 BillWoodruff 135
0 OriginalGriff 7,510
1 DamithSL 5,494
2 Sergey Alexandrovich Kryukov 4,954
3 Maciej Los 4,936
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web03 | 2.8.141223.1 | Last Updated 30 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100