I've made a class with this code :
public class Customer
{
public Customer() { }
public Customer(Customer cust)
{
ID = cust.ID;
Name = cust.Name;
FatherName = cust.FatherName;
Email = cust.Email;
}
public int ID { get; set; }
public string Name { get; set; }
public string FatherName { get; set; }
public string Email { get; set; }
}
and created this function to load list with some data:
public List<Customer> Generate_Data()
{
List<Customer> lstCustomer = new List<Customer>();
Customer customer = new Customer();
customer.ID = 1;
customer.Name = "John Cena";
customer.FatherName = "John";
customer.Email = "[email protected]";
lstCustomer.Add(new Customer(customer));
customer.ID = 2;
customer.Name = "Mokesh";
customer.FatherName = "Rajnikant";
customer.Email = "[email protected]";
lstCustomer.Add(new Customer(customer));
customer.ID = 3;
customer.Name = "Bilal Ahmad";
customer.FatherName = "Kashif";
customer.Email = "[email protected]";
lstCustomer.Add(new Customer(customer));
customer.ID = 4;
customer.Name = "Chin Shang";
customer.FatherName = "Shang Woe";
customer.Email = "[email protected]";
lstCustomer.Add(new Customer(customer));
return lstCustomer;
}
returning this list to bind with the grid. The code is :
List<Customer> lstCustomer = new List<Customer>();
lstCustomer = Generate_Data();
GridView1.DataSource = lstCustomer;
GridView1.DataBind();
My questions are :
I added 4 textboxes and a button to an aspx page with the names:
Id,Name,FatherName,EmailWhen I click on the button, I want add the new values of the textboxes to gridview1 row. I want to add a row to the gridview dynamically.If I define an empty gridview, how can I add my textbox values to gridview rows? Is not equal method with question1 ?