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

[Solved] Mode not switching to normal after item update

1 Answer 129 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mahipal
Top achievements
Rank 1
Mahipal asked on 01 May 2009, 08:51 PM

When I update an item in RadGrid, it updates my datasource but doesn't switch back to normal mode. The item still shows in edit mode. Here is what I have.

<telerik:RadGrid ID="RadGrid1" ShowStatusBar="true" GridLines="None" runat="server" AllowAutomaticDeletes="True" 
        AllowAutomaticInserts="True" OnNeedDataSource="RadGrid1_NeedDataSource" PageSize="5" 
        AllowAutomaticUpdates="True" AllowPaging="True" MasterTableView-AllowAutomaticInserts="true" 
        AutoGenerateColumns="True" AutoGenerateDeleteColumn="true" AutoGenerateEditColumn="true"   
        OnInsertCommand="RadGrid1_InsertCommand" OnUpdateCommand="RadGrid1_UpdateCommand" 
         Skin="Web20" OnDeleteCommand="RadGrid1_DeleteCommand" OnColumnCreated="RadGrid1_ColumnCreated">  
        <PagerStyle Mode="NextPrevAndNumeric" /> 
        <MasterTableView CommandItemDisplay="Top" Width="90%" DataKeyNames="id" > 
            <Columns> 
            </Columns> 
        </MasterTableView>   
    </telerik:RadGrid> 
 
 
protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)  
    {  
        GridDataItem gridEditFormItem = (GridDataItem)e.Item;  
        Hashtable ht = new Hashtable();  
        gridEditFormItem.ExtractValues(ht);  
        String ID = string.Empty;  
        foreach (DictionaryEntry entry in ht)  
        {  
            if (entry.Key.Equals("id"))  
            {  
                ID = entry.Value.ToString();  
                break;  
            }  
        }  
        DataTable myTable = (DataTable)this.Session["myDatatable"];  
        DataRow[] rowList = myTable.Select("id = '" + ID.ToString() + "'");  
        foreach (DataRow dr in rowList)  
        {  
            foreach (DictionaryEntry entry in ht)  
            {  
                if (!entry.Key.Equals("id"))  
                    dr[entry.Key.ToString()] = entry.Value;  
            }  
        }  
        Session["myDatatable"] = myTable;  
        RadGrid1.Rebind();  
    } 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 04 May 2009, 05:51 AM
Hello Mahipal,

Since you are updating your grid using manual code, you would have to set  AllowAutomaticUpdates, AllowAutomaticInserts and AllowAutomaticDeletes to false, so that the edit form would close automatically after an update. These properties of the grid are set to true only when automatic operations and datasource controls are preferred wherein manual code is not required.

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