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

grid fails to refresh with onneeddatasource after insert

1 Answer 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Minh
Top achievements
Rank 1
Minh asked on 15 Aug 2011, 05:40 PM
Hi,

I modified the code from ComboInGridExample to use onneeddatassource for my project. after clicking insert, my project inserts fine. It fails to close the edit form and refresh the grid to show the new inserted row though. The following contains my C# code:

 

 

protected void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e)  

try  

//Get the GridEditFormInsertItem of the RadGrid 

 

GridDataInsertItem insertedItem = (GridDataInsertItem)e.Item;  

RadComboBox RadComboboxUnloadType = insertedItem.FindControl("RadComboBoxUnloadType") as RadComboBox;  

RadDatePicker EventStartDateTime = (RadDatePicker)insertedItem["EventStartDateTime"].Controls[0];  

RadDatePicker EventEndDateTime = (RadDatePicker)insertedItem["EventEndDateTime"].Controls[0];  

WellVentData WellVent = new WellVentData();  

WellVent.UpdateInsertEvent(CAI,

RadComboboxUnloadType.SelectedValue.ToString(),

EventStartDateTime.SelectedDate.ToString(),

EventEndDateTime.SelectedDate.ToString(),

(insertedItem["CountofEvents"].Controls[0] as RadNumericTextBox).Text,  

(insertedItem["SalesLinePressure"].Controls[0] as RadNumericTextBox).Text, 
(insertedItem["ShutInPressure"].Controls[0] as RadNumericTextBox).Text,  

(insertedItem["FOpHierarchy_ID"].Controls[0] as TextBox).Text); 

catch (Exception ex)  

{

RadGrid1.Controls.Add(new LiteralControl("Unable to insert Event. Reason: " + ex.Message));

 e.Canceled = true;

 

}

}

********The following contains the aspx code******************

 

<

 

 

telerik:RadGrid ID="RadGrid1" GridLines="None" AutoGenerateColumns="False"

 

 

 

runat="server" AllowPaging="True" AllowSorting="True"

 

 

 

OnItemDataBound="OnItemDataBoundHandler"

 

 

 

AllowAutomaticUpdates="True" AllowAutomaticInserts="True"

 

 

 

ShowStatusBar="True" AllowFilteringByColumn="True"

 

 

 

CellSpacing="0" EnableAJAX="True" onneeddatasource="RadGrid1_NeedDataSource"

 

 

 

oninsertcommand="RadGrid1_InsertCommand"

 

 

 

onupdatecommand="RadGrid1_UpdateCommand"

 

 

 

ondeletecommand="Rad" AllowAutomaticDeletes="True" >

 

 

 

 

 

 

 

<MasterTableView ShowFooter="false" DataKeyNames="ResultsID" EditMode="InPlace" CommandItemDisplay="TopAndBottom">

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 16 Aug 2011, 09:05 AM
Hello Minh,

RadGrid will stay in edit/insert mode if you perform manual updates/inserts by setting AllowAutomaticUpdates or AllowAutomaticInserts to true. I suppose this is the reason for this issue. Please try setting these properties to false, as they are required only for AutomaticOperations.

Thanks,
Shinu.
Tags
Grid
Asked by
Minh
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or