Manually insert and update from RadGrid

1 posts, 0 answers
  1. Mohammed
    Mohammed avatar
    1 posts
    Member since:
    Dec 2013

    Posted 14 Dec 2013 Link to this post

    Requirements

    RadControls version
    .NET version
    Visual Studio version
    programming language
    browser support

    all browsers supported by RadControls

    I created Radgrid using this code 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="grdMain">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="grdMain"></telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
       <telerik:RadGrid ID="grdMain" runat="server" OnInsertCommand="grdMain_InsertCommand" OnUpdateCommand="grdMain_UpdateCommand" >
                <MasterTableView EditMode="InPlace" CommandItemDisplay="Top"  AutoGenerateColumns="False" >
                <Columns>
                     <telerik:GridBoundColumn  DataField="Id" DataType="System.Int32"
                       HeaderText="Id" Visible="true" UniqueName="Id" ReadOnly="true">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="MinValue"
     
    DataType="System.Int32"
                        FilterControlAltText="Filter MinValue column"
     
    HeaderText="MinValue"
                        SortExpression="MinValue" UniqueName="MinValue">
                          <ColumnValidationSettings
     
    EnableRequiredFieldValidation="true" RequiredFieldValidator-ControlToValidate="">
                            <RequiredFieldValidator ForeColor="Red"
     
    ErrorMessage="*"></RequiredFieldValidator>
                          </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="MaxValue"
     
    DataType="System.Int32"
                        FilterControlAltText="Filter MaxValue column"
     
    HeaderText="MaxValue"
                        SortExpression="MaxValue" UniqueName="MaxValue">
                       <ColumnValidationSettings
     
    EnableRequiredFieldValidation="true">
                            <RequiredFieldValidator ForeColor="Red"
     
    ErrorMessage="*"></RequiredFieldValidator>
                          </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ResultDate"
     
    DataType="System.DateTime"
                        FilterControlAltText="Filter ResultDate column"
     
    HeaderText="ResultDate"
                        SortExpression="ResultDate" UniqueName="ResultDate">
                          <ColumnValidationSettings
     
    EnableRequiredFieldValidation="true">
                            <RequiredFieldValidator ForeColor="Red"
     
    ErrorMessage="*"></RequiredFieldValidator>
                          </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ResultValue"
     
    DataType="System.Int32"
                        FilterControlAltText="Filter ResultValue column"
     
    HeaderText="ResultValue"
                        SortExpression="ResultValue" UniqueName="ResultValue">
                          <ColumnValidationSettings
     
    EnableRequiredFieldValidation="true">
                            <RequiredFieldValidator ForeColor="Red"
     
    ErrorMessage="*"></RequiredFieldValidator>
                          </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                     <telerik:GridEditCommandColumn uniqueName="EditCommandColumn"></telerik:GridEditCommandColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>

    and in the code behind i created two methods for insert and update as folloew

    protected void grdMain_InsertCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
    {
        AnalyzerResultBO _BO = new AnalyzerResultBO();  //Business object
     
        GridEditableItem editedItem = e.Item as GridEditableItem;
        Hashtable InputValues = new Hashtable();
        //The GridTableView will fill the values from all editable columns in the hash
          e.Item.OwnerTableView.ExtractValuesFromItem(InputValues, editedItem);
     
        _BO.MaxValue = int.Parse(InputValues["MaxValue"].ToString());
        _BO.MinValue = int.Parse(InputValues["MinValue"].ToString());
        _BO.ResultValue = int.Parse(InputValues["ResultValue"].ToString());
        _BO.ResultDate = InputValues["ResultDate"].ToString();
     
    }
     
    protected void grdMain_UpdateCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
    {
        AnalyzerResultBO _BO = new AnalyzerResultBO(); //business object
     
        GridEditableItem editedItem = e.Item as GridEditableItem;
        Hashtable InputValues = new Hashtable();
        //The GridTableView will fill the values from all editable columns in the hash
        e.Item.OwnerTableView.ExtractValuesFromItem(InputValues, editedItem);
     
        _BO.MaxValue = int.Parse(InputValues["MaxValue"].ToString());
        _BO.MinValue = int.Parse(InputValues["MinValue"].ToString());
        _BO.ResultValue = int.Parse(InputValues["ResultValue"].ToString());
        _BO.ResultDate = InputValues["ResultDate"].ToString();
        
    }

    in the insert method I can't get any value using ExtractValuesFromItem  and in the update method I get the old value not the updated value.

    Please help.
    Thanks

    PROJECT DESCRIPTION
    [enter description here, together with step-by-step instructions on how to use the project]
Back to Top