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

[Solved] Cannot get values of cells

4 Answers 145 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Patrick Stecker
Top achievements
Rank 1
Patrick Stecker asked on 21 Oct 2009, 11:42 PM
Hello,

We are trying to use the RadGrid like an "excel" grid, and it works fine, however when we try to loop through each cell, the "Text" property always shows up as "&nbsp".  However, when we use the "ExtractValues()" method, we can get the proper values.  All is fine and dandy, until we hit a column that is "ReadOnly".  The ReadOnly cell does not show up in the ExtractValues variable (which makes sense), but now I am back to square one as to how to get value from the cells by UniqueName.  We are using Telerik version 2009.2.826.35 (2009 Q2).  

foreach (GridDataItem row in RadGrid1.MasterTableView.Items) 
  var cell = row["MyUniqueName"]; 
  Response.Write(cell.Text); // This comes out to be " " each time. 


Any help in directing me in the right direction would be greatly appreciated.  Thanks.

Best Regards,

Patrick

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 Oct 2009, 04:54 AM
Hello Patrick,

You would have to access the controls for each column and then retrieve the edited text, as the items in an excel grid would be in edit mode. Here is an example:
c#:
 foreach (GridEditableItem item in RadGrid1.MasterTableView.GetItems(GridItemType.EditItem)) 
        { 
            TextBox txtbx = (TextBox)item["MyUniqueName"].Controls[0]; 
        } 

Hope this helps..
Princy.
0
Patrick Stecker
Top achievements
Rank 1
answered on 22 Oct 2009, 03:41 PM
But the column is *NOT* in edit mode (the row is, but there are some 'readonly' fields that I am trying to get access to).

It just seems like a "kludge" (for lack of a better word).  If we traverse the Editable GridItems, then why wouldn't the "Text" value of these items show the appropriate data?  Am I missing the logic in this?  Thanks for your reply.

Best Regards,

Patrick
0
Sebastian
Telerik team
answered on 27 Oct 2009, 03:10 PM
Hello Patrick,

How to extract values from non-editable and editable grid cells you can see from the resources linked below:

http://demos.telerik.com/aspnet-ajax/grid/examples/programming/accessingcellsandrows/defaultcs.aspx
http://demos.telerik.com/aspnet-ajax/grid/examples/overview/defaultcs.aspx (Section Insert/Update/Delete -> Extract values

http://www.telerik.com/help/aspnet-ajax/grdaccessingcellsandrows.html
http://www.telerik.com/help/aspnet-ajax/grddataeditingsupport.html

Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Patrick Stecker
Top achievements
Rank 1
answered on 27 Oct 2009, 04:20 PM
Hello Sebastian,

This link:

http://demos.telerik.com/aspnet-ajax/grid/examples/overview/defaultcs.aspx

Solved my ExtractValues problem and so I'll mark this as answered.  

Thanks!

Best Regards,

Patrick
Tags
Grid
Asked by
Patrick Stecker
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Patrick Stecker
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or