c# - Saving gridview updated data to SQL Server? -
i can save data in gridview unable datasource. there missing line of code or there missing?
here's code:
public marksheet(object val1) { initializecomponent(); string connectionstring = null; sqlconnection conn; connectionstring = "server=localhost\\sqlexpress;integrated security=sspi;database=jms"; sqldataadapter sda6 = new sqldataadapter("select * grades class_code='" + val1 + "'", connectionstring); conn = new sqlconnection(connectionstring); datatable dt5 = new system.data.datatable(); sda6.fill(dt5); gridcontrol1.datasource = dt5; } private void gridcontrol1_embeddednavigator_buttonclick(object sender, navigatorbuttonclickeventargs e) { if (e.button.buttontype == devexpress.xtraeditors.navigatorbuttontype.endedit) { if (messagebox.show("do want commit changes current record?", "confirm commit", messageboxbuttons.yesnocancel, messageboxicon.question) != dialogresult.no) { gridview1.closeeditor(); gridview1.updatecurrentrow(); } } } private void gridview1_cellvaluechanged(object sender, cellvaluechangedeventargs e) { //?? there i'm missing here? if yes, be? }
when make changes grid control, changes reflected in datasource, in case datatable. if think logically, seems correct grid control bound datatable , not aware how datatable gets populated.
now can see datatable populated using dataadapter. need call dataadapter.update(datatable) method push changes database.
as described here - posting data connected database
Comments
Post a Comment