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

[Solved] RadGrid: read data from javascript

1 Answer 159 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alessandro Distefano
Top achievements
Rank 1
Alessandro Distefano asked on 08 Jan 2010, 05:03 PM
Hello,
i have a problem: in my ASP page i have a RadGrid with ID="RGDati", i want to read the data into RadGrid cells via javascript;
I'm using this method:

    function readData(){
        var grid = window["<%# RGDati.ClientID %>"];
        alert(grid); // output: "undefined"
        for (var i = 0; i < grid.MasterTableView.SelectedRows.length; i++)  
        {  
            var row = grid.MasterTableView.SelectedRows[i];  
            var cellID = grid.MasterTableView.GetCellByColumnUniqueName(grid.MasterTableView.SelectedRows[i], "EmployeeID");    
            alert(cellID.innerText);  
        }
    }


but it crash because grid is "undefined"!
If I use this statement
var grid = window["<%= RGDati.ClientID %>"];
i have this error message:

Error Message:The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
Stack Trace: at System.Web.UI.ControlCollection.AddAt(Int32 index, Control child) at Telerik.Web.UI.RadAjaxControl.MoveUpdatePanel(Control initiator, Control updated)

Please, can you help me?

1 Answer, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 08 Jan 2010, 05:38 PM
The error you are receiving seems to be more of an issue of where you are placing your javascript. If you wrap them in <telerik:RadCodeBlock></telerik:RadCodeBlock> or move them out of the <head></head> tags you should be fine.
Tags
Grid
Asked by
Alessandro Distefano
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
Share this question
or