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

[Solved] GridDataInsertItem contains no data in an InPlace insert

3 Answers 226 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 02 Sep 2009, 07:09 PM
When the following code runs, the .Texts for the bound columns come back as empty strings and the .SelectedValues for the drop-down columns come back with whatever their default selection is.  EditMode is InPlace, however I'm not sure that matters since when I tried changing it to EditForms and using a GridEditFormInsertItem instead of a GridDataInsertItem the same thing happened.

<telerik:RadGrid ID="rgQuestions" runat="server" DataSourceID="dsQuestion" AutoGenerateColumns='false' Skin="Simple" 
    AllowAutomaticUpdates='false' AllowAutomaticInserts = 'false' AllowAutomaticDeletes='false'  
    OnItemDataBound='rgQuestions_ItemDataBound' OnInsertCommand='rgQuestions_InsertCommand' OnDeleteCommand='rgQuestions_DeleteCommand' OnUpdateCommand='rgQuestions_UpdateCommand' > 
        <MasterTableView EditMode='InPlace' CommandItemDisplay="Bottom" CommandItemSettings-AddNewRecordText="New Question"
            <Columns> 
                <telerik:GridEditCommandColumn ButtonType='LinkButton' /> 
                <telerik:GridBoundColumn HeaderText="Question Key" DataField="QuestionKey" UniqueName="colQuestionKey" ReadOnly="True" Display="False" /> 
                <telerik:GridBoundColumn HeaderText="Inspection" DataField="InspectionKey" UniqueName="colInspectionKey" ReadOnly="True" Display='false' /> 
                <telerik:GridBoundColumn HeaderText="#" DataField="QuestionNumber" UniqueName="colQuestionNumber" /> 
                <telerik:GridBoundColumn HeaderText='Question' DataField='QuestionText' UniqueName='colQuestionText' /> 
                <telerik:GridDropDownColumn HeaderText='Asset Type' DataField='AssetTypeKey' UniqueName='colAssetTypeKey'  
                    DataSourceID='dsAssetType' ListTextField='AssetType' ListValueField='AssetTypeKey' />    
                <telerik:GridDropDownColumn HeaderText='Asset Contents' DataField='AssetContentKey' UniqueName='colContentDesc'  
                    DataSourceID='dsAssetContent' ListTextField='ContentDesc' ListValueField='AssetContentKey' EnableEmptyListItem='true' /> 
            </Columns> 
 
            <EditFormSettings> 
                <EditColumn UniqueName="EditCommandColumn1"></EditColumn> 
            </EditFormSettings> 
        </MasterTableView> 
    </telerik:RadGrid> 
 
protected void rgQuestions_InsertCommand(object sender, GridCommandEventArgs e) 
        { 
            if (e.CommandName == RadGrid.PerformInsertCommandName) 
            { 
                GridDataInsertItem item = (GridDataInsertItem)e.Item; 
                Question q = new Question(); 
                q.InspectionKey = Int32.Parse(rcbInspections.SelectedValue); 
                q.AssetTypeKey = Int32.Parse((item["colAssetTypeKey"].Controls[0] as RadComboBox).SelectedValue); 
                //q.AssetContentKey = Int32.Parse((item["colContentDesc"].Controls[0] as RadComboBox).SelectedValue); 
                q.QuestionNumber = Int32.Parse((item["colQuestionNumber"].Controls[0] as TextBox).Text); 
                q.QuestionText = (item["colQuestionText"].Controls[0] as TextBox).Text; 
                q.Active = true
                q.Save(); 
                rgQuestions.Rebind(); 
            } 
        } 

3 Answers, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 04 Sep 2009, 02:12 PM
Hi Chris,

I recommend that you take a look at the Inserting values in-place and EditForms help topic and modify your code to use one of the ways mentioned there to insert grid row.

All the best,
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
Chris
Top achievements
Rank 1
answered on 04 Sep 2009, 02:20 PM
I actually have tried enabling automatic inserts/updates, along with a lot of other things, with the same result - for some reason all of the methods I've tried to get the new values from the grid, all give me the original values of the controls instead.  Confusingly, I have other grids in different parts of the app which are coded identically and they work.  Also I've gotten a few "invalid postback or callback argument" errors while testing this one.  That's only happened a few times and as far as I can tell at random.
0
Mira
Telerik team
answered on 09 Sep 2009, 03:12 PM
Hello Chris,

The way you get the value from the edit form highly depends on the form type and whether it is autogenerated or not.

If the issues with editing persist, I would like to ask you to send us a small working project demonstrating the described behavior. We will debug it locally and get back to you with our findings.

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.
Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Mira
Telerik team
Chris
Top achievements
Rank 1
Share this question
or