This is a migrated thread and some comments may be shown as answers.

RadGrid multiple records from a form

1 Answer 28 Views
Grid
This is a migrated thread and some comments may be shown as answers.
hamda
Top achievements
Rank 1
hamda asked on 16 Jun 2010, 06:52 AM
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:
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"));  
            }  
           
              
        } 

1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 18 Jun 2010, 12:20 PM
Hello hamda,

RadGrid is a data-bound control. You need to first insert the record into the data-source to which you have bound the grid and then rebind it.

Hope it helps.

Greetings,
Tsvetoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
hamda
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or