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

Need to update text in RadGrid fields

1 Answer 104 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kenneth Miller
Top achievements
Rank 1
Kenneth Miller asked on 20 May 2011, 09:17 PM
I have a RadGrid set up to do automatic inserts and updates. I get the edit links, which open the edit form, as it should. I can enter and retrieve the new values with no problems. However, because we are connecting to a legacy mainframe application, we have to send ALL the on screen data in one message; I can't just do a simple update of the single record I'm editing.

In order for the pop-up editing to work in the grid I'm using the OnNeedDataSource event. I believe this is causing the problem.

I have code behind the Update command for this grid (rgdDetails) to update the selected row's "ItemClass" cell. I know it's hitting this code, because the "Record Updated" message is being displayed, but the text in the cell is not being changed. Am I not handling the OnNeedDataSource event properly? Is it reloading and overwriting the data that I want to change with the original data? Or am I doing something incorrectly when trying to enumerate the cell I want to change?

        Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)
        editedItem = e.Item
        editedItem("ItemClass").Text = "Testdata"

       rgdDetails.MasterTableView.ClearEditItems()
        Master.MessagePanel.InfoMessage("Record Updated")


Here is a section of the OnNeedDataSource code. It's opening a query and setting the datasource for the grid.

 

        Dim pDate As String = _Control.SelectedDate.ToString
        Dim pStore As String = _Control.SelectedStore
        Dim pTerm As String = _Control.SelectedTerminal
        Dim pTran As String = _Control.SelectedTransaction


        If (pStore <> "0") And (pTerm IsNot Nothing) And (pTran IsNot Nothing) And (pTran <> "") Then
            Dim ds1 As DataSet = TransDetailDAL.GetTranItemsDetail(pDate, pStore, pTerm, pTran)
            rgdDetails.DataSource = ds1


            Dim dr As DataRow = TransDetailDAL.GetTranHDRDetail(pDate, pStore, pTerm, pTran)


       

1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 24 May 2011, 01:19 PM
Hello Kenneth,

Thank you  for contacting us.

Your NeedDataSource event is all right and you are correct in supposing that the data gets overwritten since each update operation the grid is being rebound and constructs itself a new from whatever data is passed to it in the NeedDataSource event. This is due to RadGrid's being a data-bound control.

I'd suggest that you take a look at the following online example, as it seems close to the scenario you have:
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/clienteditbatchupdates/defaultcs.aspx

If you need further assistance, do not hesitate to get in touch with us again.

Regards,
Tsvetoslav
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Kenneth Miller
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or