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
Post a Comment