I want to store details to a DataTable when a button is pressed and display it on a DataGridView when the add button is pressed. How can I achieve this. Please help me. Thanks a lot.
I tried this code. But I need a way to bind it with the datagrid.
DataRow dr;
DataTable dt=new DataTable();
dt.Columns.Add("LoginId", typeof(int));
dt.Columns.Add("UserFirstName", typeof(string));
dt.Columns.Add("LastName", typeof(string));
dt.Columns.Add("Password", typeof(string));
dt.Columns.Add("EmailId", typeof(string));
dt.Columns.Add("Role", typeof(string));
dt.Columns.Add("Description", typeof(string));
dr = dt.NewRow();
You can add columns to the datatable as you need, and then add rows, like this: