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

Telerik RadGrid loses values after PostBack

5 Answers 336 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bruno
Top achievements
Rank 1
Bruno asked on 15 Jan 2014, 06:38 PM
Hello, I have a RadGrid with multiples textboxes to be edited.
When i made "submit" (Postback on page) i lose all values inserted on that textboxes because RadGrid loses is values.

How can i solve this problem?

Any solution?
Thanks, Bruno F.

5 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 16 Jan 2014, 06:00 AM
Hello,

Please use Advanced Data Binding (using the NeedDataSource event)  to bind the data in grid.

You lost the because of before execute the InsertCommand/UpdateCommand event grid is already rebind the its data. Means : Radgrid1.DataSource = ""; RadGrid.DataBind(); code is executed before it reach to the InsertCommnad/UpdateCommand event.

Thanks,
Jayesh Goyani
0
Bruno
Top achievements
Rank 1
answered on 16 Jan 2014, 10:06 AM
Jayesh GoyaniThanks Jayesh but, i don't wanna reload the data again (get data from database), I want to get the values of the textboxes that i change.

Is that possible NeedDataSource?

Because what i understant is that NeedDataSource will get the data again for database for example and i don't wanna that, i want get the values that i inserted in textboxes placed on grid.

Any solution?
Thanks.
0
Viktor Tachev
Telerik team
answered on 21 Jan 2014, 07:59 AM
Hello Bruno,

In order to save the values entered in an EditForm you could different approached depending on your scenario.

If you have DataSource for RadGrid that supports automatic operations you could update the values automatically. This method is illustrated in a documentation article here. Also a live example is available in this online demo.

If the data source does not support automatic operations you would need to manually perform the update. You could use handler for RadGrid's UpdateCommand event in order to update the values. Additional information on manual CRUD operations is available in this article and also in an online demo here.


Regards,
Viktor Tachev
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
JJ
Top achievements
Rank 2
answered on 24 Jul 2014, 07:44 AM
Hi

I build my Rad Grid dynamically:

 1. create columns in my user-control OnInit event
 2. create controls of the columns in the OnItemCreated event
 3. bind the data in the OnItemDataBound event
 4. set the RadGrid data-source property in the OnNeedDataSource event
 5. parent page uses Ajax update panel settings and add the User Control dynamically with load each time in its OnInit event..
 6. do not want to use EditForm or Batch mode just dynamically controls in columns in radGrid and save

All is running smooth, but I loos my values after PostBack when I click on my save button and/or the RadGrid Save button. 

I add the OnUpdateCommand event and AllowAutomaticUpdates="true" <not firing the event>

what am I missing?
 
0
JJ
Top achievements
Rank 2
answered on 25 Jul 2014, 01:45 PM
thanks mannn

solution:

do not have to use ItemCreate nor ItemBound events...

1. Parent Page with Ajax Settings (Rad Grid Light Binding) 
   a. use Load Event and onChange events of controls to determine diffrent scenarious of child controls 
   b. Build User Control each time on its OnInit Event
2. Child User Control (Advance Binding - OnNeedDataSource)
   a. use OnInit Event to create the columns (to deep copy from the temp GridTemplateColumn in ASP.net)
   b. use RadAjaxManagerProxy
            c. OnInit Event (build columns)
            i.   Columns must use ItemTemplate and EditTemplage in the temp GridTemplateColumn with Binding Text='<%# Bind("TimeInterval") %>' 
            ii.  Add all the diffrent controls like checkbox, radnumericbox, radtextbox, datetimepickers, combobox...
            iii. Controls must use events:
            - OnInit 
            * (set Unique Id's, but Id's must be stored in server object or session variable, becuase it must be the same on each init create)
            * (set the visibility of the Control you want to use to true and the other to false, thus if this is the dataType and control to use set the visibility to true else false
            - OnDataBinding 
            * (bind to server object with correct dataField, can get dataField from GridTemplateColumn)
            - OnPreRender 
            * (set the column and row selectable, this is important if you want to make RadGrid like Excell data input and use the EditTemplate, this is very important for saving of data)
                   - OnTextChange (validation with Session variables)
            - EditItemTemplate contains OnInit and OnTextChange events
            - ItemTemplate contains OnInit and OnDataBinding events and OnPreRender
Tags
Grid
Asked by
Bruno
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Bruno
Top achievements
Rank 1
Viktor Tachev
Telerik team
JJ
Top achievements
Rank 2
Share this question
or