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

GridDataItem["colName"].Text returns ' '

1 Answer 444 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 07 Jul 2009, 09:15 PM
Relevant code:
ASP: 
<telerik:GridBoundColumn DataField="TaskKey" UniqueName="colTaskKey" ReadOnly="true" Display="true" /> 
 
 
C#: 
protected void grdAssign_UpdateCommand(object sender, GridCommandEventArgs e) 
 { 
    GridDataItem item = (GridDataItem)e.Item; 
    int taskKey = Int32.Parse(item["colTaskKey"].Text); 

The column is being displayed only for debugging purposes, so I can verify that yes, it is being populated with the correct data.  When I run this, Int32.Parse throws a FormatException because the string being passed to it is "&nbsp;".  I have not been able to figure out why this is.


1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 08 Jul 2009, 04:21 AM
Hello Chris,

In the UpdateCommand, you can only access the GridEditableItem, i.e., the textbox for the bound column but if you want to access the parent item, you would have to try out the following code:
c#:
protected void grdAssign_UpdateCommand(object sender, GridCommandEventArgs e)  
 {  
    GridEditFormItem editItem = (GridEditFormItem)e.Item; // EditForms mode 
    string strtxt = (editItem["colTaskKey"].Controls[0] as TextBox).Text; // get the updated text for a column  
    string strtxt1 = editItem.ParentItem["colTaskKey"].Text;//get the original text for the column            
 } 

Thanks
Princy.
Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or