how to bind data to gridview in windowsApplication C# -
i have below code in button. clicking button , retrieve data sql server , display in gridview. can retrieve , filled in dt.but data not shown in grid view, theproblem? please crack me out.
private void gvipretrieve_click(object sender, eventargs e) { connstring(); conn.open(); using (sqlcommand cmd = new sqlcommand("gvretrieve_ip", conn)) { cmd.commandtype = commandtype.storedprocedure ; using (sqldataadapter sda = new sqldataadapter(cmd)) { using (datatable dt = new datatable()) { sda.fill(dt); datagridview2.datasource = dt; } } } }
make sure there no gridview in windows application.there control show data in form of rows , columns i,e datagridview.here best useful link binding data sql server database through datatable
Comments
Post a Comment