c# - How to add row in DataGridView programmatically -


here i've tried code. but, problem that, doesn't display data.

here code

try {     datatable dt = new datatable();     con.open();      dt.load(new mysqlcommand("select variant_name tblvariant_product product_name='" + cboproduct.text + "'", con).executereader());      datacolumn col = dt.columns.add(new datacolumn("quantity", typeof(int32));     col.allowdbnull = false;      datarow row = dt.newrow();     row["variant_name"] = "total";     row["quantity"] = 0;     dt.rows.add(row);      datagridview2.datasource = dt;     con.close(); } catch (exception) { } 

write:

dt.acceptchanges();  

after:

dt.rows.add(row); 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -