Click here to Skip to main content
15,907,328 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys ,

as i told in the title , how can i refresh the datas in the GridView after i update the value? Winform ?

i tried grd.Refresh(); grd.Update(); but didnt work . the code is below.



C#
string kayitguncelle = "UPDATE Kisi SET IDGrup=@IDGrup,ogrNo=@ogrNo,Adi=@Adi,SoyAdi=@SoyAdi,Telefon=@Telefon,VeliAd=@VeliAd,VeliTel=@VeliTel,Adres=@Adres";
cmd = new OleDbCommand(kayitguncelle, baglanti);
baglanti.Open();
cmd.Parameters.Add("@IDGrup", OleDbType.Integer).Value = IDGrup;
cmd.Parameters.Add("@ogrNo", OleDbType.Char, 50).Value = ogrNo;
cmd.Parameters.Add("@Adi", OleDbType.Char, 50).Value = Adi;
cmd.Parameters.Add("@SoyAdi", OleDbType.Char, 50).Value = SoyAdi;
cmd.Parameters.Add("@Telefon", OleDbType.Char, 50).Value = Telefon;
cmd.Parameters.Add("@VeliAd", OleDbType.Char, 50).Value = VeliAd;
cmd.Parameters.Add("@VeliTel", OleDbType.Char, 50).Value = VeliTel;
cmd.Parameters.Add("@Adres", OleDbType.Char, 50).Value = Adres;



try
{

    cmd.ExecuteNonQuery();
    ((MainForm)Application.OpenForms["MainForm"]).grd.Refresh();

    MessageBox.Show("Succesful...blabla");
    baglanti.Close();


}
Posted
Updated 21-Sep-12 23:08pm
v2

on gridview_rowdeleting event and rowupdating event

bind your gridviw.

put your gridview binding code in a separate method suppose bindGriddata()

then call bindgriddata() method in rowdeleting and updating events.

or

after delete,insert and update command fired then you need to rebind your grid.
if you again rebind your grid it will show latest record.

Hope it will helps you and let me know if you want to more information.
 
Share this answer
 
v2
Comments
beratxt 22-Sep-12 5:40am    
Thanks i ve just done it..But how can i delete the value that i choose in the gridview ? im using telerik form..but there is no RowEnter event ? can u help if you know ..thanks for in advance
Refresh() And Update() Methods will not refresh your grid data.

You must to call Rebind Your grid with latest DataSource Again. it will refresh your grid data.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900