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

RadGrid created programmaticaly with Itemplate & IbindableTemplate / Unable to get extractvalues

1 Answer 114 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jean
Top achievements
Rank 1
Jean asked on 29 Aug 2012, 08:44 AM
Hello,

I have a radgrid created dynamically. It contains an GridTemplateColumn with an ItemTemplate and an EditItemTemplate created programmatically too.
The MasterTableView's EditMode is set to InPlace. When i update my row, I fire the UpdateCommand event, but the hashtable does not contain any value.
if (e.CommandName == RadGrid.UpdateCommandName)
{
    if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode))
    {
        GridEditableItem item = (GridEditableItem)e.Item;
 
        TextBox txtAmount = new TextBox();
        TextBox txtQuantity = new TextBox();
 
        int ID_Profil = Convert.ToInt32(item.GetDataKeyValue("ID_Profil"));
        if (ID_Profil != 0)
        {
            DataTable objectifsTable = this.GridSource;
            //Locate the changed row in the DataSource
            DataRow[] changedRows = objectifsTable.Select("ID_Profil = " + ID_Profil.ToString());
 
            if (changedRows.Length != 1)
            {
                e.Canceled = true;
                return;
            }
 
            //Update new values
            Hashtable newValues = new Hashtable();
 
            grd_objectifs.Items[item.ItemIndex].ExtractValues(newValues);
                changedRows[0].BeginEdit();
                try
                {
                    foreach (DictionaryEntry entry in newValues)
                    {
                        changedRows[0][(string)entry.Key] = entry.Value;
                    }
                    changedRows[0].EndEdit();
                }
                catch (Exception ex)
                {
                    changedRows[0].CancelEdit();
                    e.Canceled = true;
                }
        }
    }
}

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 03 Sep 2012, 08:25 AM
Hi,

In order to use ExtractValuesFromItem method when you are using Template columns you should provide an overload for this method in your class declaration as described in the last section of this help topic.

Give this approach a try and check whether you get the expected results.

Greetings,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Jean
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or