private void GET_Click(object sender, EventArgs e)
 {
     user queryobject = new user();
     queryobject.Address = Address_TextBox.Text;
     queryobject.User_name = User_Name_TextBox.Text;
     queryobject.Email_id = Email_TextBox.Text;
     if (UserRole.SelectedValue != null)
     {
         queryobject.User_role_id = int.Parse(UserRole.SelectedValue.ToString());
     }
     queryobject.Phone = Phone_TextBox.Text;
     queryobject.Passwrod = Password_textBox1.Text;
     List<object> dataRet = queryobject.get();
     List<user> data = new List<user>();
     foreach (object o in dataRet)
     {
         data.Add(o as user);
     }
     var _bind = data.Select(a => new
     {
         UserID = a.User_id,
         Address = a.Address,
         Email = a.Email_id,
         Phone = a.Phone,
         Name = a.User_name,
         UserRole = a.User_role_id,
         Password = a.Passwrod,
     }).ToList();
     UserDataGrid.DataSource = _bind;
     utility.AddDeleteAndEditButton(UserDataGrid);
     // Link for getting buttons working as part of grid.
     // http://stackoverflow.com/questions/10769316/add-a-button-in-a-new-column-to-all-rows-in-a-datagrid
     UserDataGrid.Update();
 }
        private void button1_Click(object sender, EventArgs e)
        {
            // Create Object
            user newuser = new user();

            // Assign read form's fields to object's fields
            newuser.Address = Address_TextBox.Text;
            newuser.User_name = User_Name_TextBox.Text;
            newuser.Email_id = Email_TextBox.Text;
            newuser.Passwrod = Password_textBox1.Text;
            newuser.Phone = Phone_TextBox.Text;
            newuser.User_role_id = int.Parse(UserRole.SelectedValue.ToString());
            // Call Save
            newuser.save();
            // http://tech.pro/tutorial/776/csharp-tutorial-binding-a-datagridview-to-a-collection
            this.Close();
        }
        /// <summary>
        /// Object Specific function
        /// </summary>
        /// <param name="dr"></param>
        /// <returns></returns>
        public override object convertFromReader(OleDbDataReader dr)
        {
            user gotUserFromDB = new user();
            // Gaurav - Replace below as first one
            gotUserFromDB.address = dr[DatabaseCoachingInst.User.Address.ToString()].ToString();
            gotUserFromDB.Passwrod = dr["Password"].ToString();
            gotUserFromDB.Phone = dr["Phone"].ToString();
            gotUserFromDB.User_name = dr["User_Name"].ToString();
            gotUserFromDB.User_role_id = int.Parse(dr["User_Role_ID"].ToString());
            gotUserFromDB.Email_id = dr["email"].ToString();
            gotUserFromDB.User_id = int.Parse(dr["user_id"].ToString());

            // write similar code for other fields.
            return gotUserFromDB;
        }