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

[Solved] ExtractValuesFromItem returns all null values

6 Answers 443 Views
Grid
This is a migrated thread and some comments may be shown as answers.
wdudek
Top achievements
Rank 1
wdudek asked on 24 Sep 2009, 08:45 PM
I have a hierarchical grid that uses Linq and the entity framework to do custom paging, at some point I noticed that the edit function was no longer working. The problem is that whenever I try to get the values using the following code they all come back as null.
The item.SavedOldValues is populated as I would expect.  I can paste the aspx and c# but since there is ALLOT of it I figured I'd wait until someone asks for it. Right now I'm really looking for suggestions.

protected void rgEditor_UpdateCommand(object source, GridCommandEventArgs e)  
    {  
 
          
        GridEditableItem item = e.Item as GridEditableItem;  
   
        Hashtable edited = new Hashtable();  
        item.OwnerTableView.ExtractValuesFromItem(edited, item);  
        //at this point edited has all the keys I would expect but the valeus are all null  
 
    } 


Thanks

Bill

6 Answers, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 25 Sep 2009, 02:46 PM
Hello Bill,

I would like to ask you what edit mode you use for your RadGrid?
If it is inplace editor or edit form, you can see how the ExtractValuesFromItem method works in this demo.
If you use UserControl or FormTemplate, please take a look at the Updating values using UserControl/FormTemplate help topic to see how it is done.

Kind regards,
Mira
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
wdudek
Top achievements
Rank 1
answered on 28 Sep 2009, 12:34 PM
Hi, I am usign the In Place edit mode, I'll take a look a the links you provided and post my results.

Thanks

Bill
0
wdudek
Top achievements
Rank 1
answered on 28 Sep 2009, 04:52 PM
Here's the problem, the first thing I was doing is calling the following line of code which I apparently didn't even need.

e.Item.Edit =

false;

 

0
Akber Ali
Top achievements
Rank 1
answered on 29 Oct 2009, 02:25 AM
I am very new to Rad Controls. I started using RADGrid for the first time and it was very frustrating experience.. I mean why i will be writing to this forum for such a small thing. Ok let me describe the problem.

I have a simple RadGrid with two bound columns from a List Type Data Source. Look at the following declaration
<MyControls:MyGrid ID="grd_SiteMap" runat="server"
        <MasterTableView DataKeyNames="SiteMapGUID" EditMode="InPlace" Width="100%" AllowAutomaticUpdates="true"
            <Columns> 
                <telerik:GridBoundColumn  DataField="PageID" SortExpression="PageID" HeaderText="Page ID" ColumnEditorID="GridTextBoxColumnEditor1" UniqueName="lun" /> 
                <telerik:GridBoundColumn DataField="ParentID" SortExpression="ParentID" HeaderText="Parent ID" ColumnEditorID="GridTextBoxColumnEditor2"  /> 
                <telerik:GridBoundColumn DataField="Sequence" SortExpression="Sequence" HeaderText="Order" ColumnEditorID="GridTextBoxColumnEditor3" / 

in the code behind I am trying to grab all the values i.e. values edited/changed by the user. In fact all the values including changed and those unchanged.
     protected override void OnItemCommand(GridCommandEventArgs e) 
        { 
            string _commandName = e.CommandName; 
            switch (_commandName) 
            { 
                case "Update"
                    
                    string abc = e.Item.OwnerTableView.Columns.FindByDataField("PageID").ToString(); 
                    GridEditableItem editedItem = e.Item as GridEditableItem; 
 
                                       
                    GridEditableItem item = e.Item as GridEditableItem; 
                    Hashtable newValues = new Hashtable(); 
                    item.OwnerTableView.ExtractValuesFromItem(newValues, item); 
but the problem is that Hashtable is populated with old values. I thought that there will be a simple way of grabbing the current row and then with the help of simple foreach loop I will peek into each cell value. But this not the case of i am making some blunder.
Please help to boost my confidence

Also let me add that I am using an Ajax Panel. So could this be the problem.


0
Iana Tsolova
Telerik team
answered on 03 Nov 2009, 12:19 PM
Hi,

I followed your scenario and prepared a sample project attached to this post. I was able to extract values successfully on my side. Check it out and let me know what differs in your case.

Kind regards,
Iana
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
Akber Ali
Top achievements
Rank 1
answered on 03 Nov 2009, 02:34 PM
Thanks lana

finally i figured out that the data source should be provided in event called OnNeedDataSource. By doing so i am able to do what ever i want. Earlier I was providing the Data Souce on Page Load.

Thanks anyways.
Tags
Grid
Asked by
wdudek
Top achievements
Rank 1
Answers by
Mira
Telerik team
wdudek
Top achievements
Rank 1
Akber Ali
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or