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

How to save data from dynamically column [telerik gridview] [need help]

1 Answer 143 Views
Grid
This is a migrated thread and some comments may be shown as answers.
desuke
Top achievements
Rank 1
desuke asked on 07 Dec 2010, 05:56 AM
Hi all,
I've some problem (I weakness in english language but I'll try to explain.)  
Firstly, I've created dynamically column from telerik gridview but I couldn't save new data to datatable

About telerik gridview that I try to this code 

 void grid_UpdateCommand(object source, GridCommandEventArgs e)
    {
        Hashtable newValues = new Hashtable();
        GridEditableItem item = e.Item as GridEditableItem;
        item.OwnerTableView.ExtractValuesFromItem(newValues, item);
        Response.Write("Updated Name: " + newValues["ContactName"].ToString());

    }
 void grid_UpdateCommand(object source, GridCommandEventArgs e)
    {
        Hashtable newValues = new Hashtable();
        GridEditableItem item = e.Item as GridEditableItem;
        item.OwnerTableView.ExtractValuesFromItem(newValues, item);
        Response.Write("Updated Name: " + newValues["ContactName"].ToString());

    }
 void grid_UpdateCommand(object source, GridCommandEventArgs e)
    {
        Hashtable newValues = new Hashtable();
        GridEditableItem item = e.Item as GridEditableItem;
        item.OwnerTableView.ExtractValuesFromItem(newValues, item);
        Response.Write("Updated Name: " + newValues["ContactName"].ToString());

    }
void grid_UpdateCommand(object source, GridCommandEventArgs e)
   {
       Hashtable newValues = new Hashtable();
       GridEditableItem item = e.Item as GridEditableItem;
       item.OwnerTableView.ExtractValuesFromItem(newValues, item);
       Response.Write("Updated Name: " + newValues["ContactName"].ToString());
 
   }

this code is perform to gather new value (when you key in new value in editable textbox),In runtime mode will through to   grid_UpdateCommand method. that's ok  (I can show new value )

But my purpose want to loop all new value (when you key in new value) into my Data-table 
as following 
Hashtable newValues = new Hashtable();
            foreach (GridEditableItem Item in grid.MasterTableView.Items)
            {
               
                Item.OwnerTableView.ExtractValuesFromItem(newValues, (GridEditableItem)Item);
                string str = newValues[0].ToString();
            }

But I couldn't  get new value when I loop from grid (I couldn't use ExtractValuesFromItem method it displayed error message as "Unable to cast object of type 'MyItemTemplate' to type 'System.Web.UI.IBindableTemplate'."

How should I do this problem ? 

Thanking in advance
 Bhadhai

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 10 Dec 2010, 09:03 AM
Hello Bhadhai,

Note that the RadGrid.MasterTableView.Items collection contains GridDataItems and not the items that are in edit mode. To get a reference to the currently edited items, you should use the RadGrid.EditItems collection instead. For more information on the matter, I would suggest that you review the following help article (pay special attention to the "Using the EditItems collection" section):

Edit forms

I hope this helps.

Greetings,
Martin
the Telerik team
Browse the vast support resources we have to jumpstart 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
desuke
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or