hi,
I have a regular form with textboxes and dropdowns when I fill this form then press a button it should add this info to a grid of one record that I just entered from the form. The problem is I want to add multiple records to this grid, but when i fill again then insert it to the grid it replaces the old record I inserted earlier. I use a Select Function that takes the id of the record inserted then rebind it to the RadGrid.
How can I add multiple records to a grid from a form??
This is the grid needDataSource function:
I have a regular form with textboxes and dropdowns when I fill this form then press a button it should add this info to a grid of one record that I just entered from the form. The problem is I want to add multiple records to this grid, but when i fill again then insert it to the grid it replaces the old record I inserted earlier. I use a Select Function that takes the id of the record inserted then rebind it to the RadGrid.
How can I add multiple records to a grid from a form??
This is the grid needDataSource function:
| protected void grdInsertPerson_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) |
| { |
| List<Person> per = null; |
| List<Person> perResult = new List<Person>(); |
| //per = Person.SelectCmd(-1, "", -1, -1, "", "", -1,"", 1); |
| try |
| { |
| //per = Person.SelectCmd(-1, "", -1, -1, "", "", -1, Session["PersonId"].ToString(), 1,-1);//count1 |
| per = Person.SelectCmd(-1, "", -1, -1, "", "", -1, "", 1, -1);//count1 |
| if (per.Count > 0) |
| { |
| for (int i = 0; i < per.Count; i++) |
| { |
| if (per[i].PersonId == Session["PersonId"].ToString()) //the session store the id of the person inserted in the form |
| { |
| perResult.Add(per[i]); |
| } |
| } |
| grdInsertPerson.Visible = true; |
| grdInsertPerson.DataSource = perResult; |
| } |
| } |
| catch (Exception exp) |
| { |
| Page.Validators.Add(new CheckPoints.StaticValidator("Can't show data")); |
| } |
| } |