
hi,
we have an ASP.NET website.
Within here a user control.
THis user control contains two RADGRID controls.
Grid 1 is populated with data. Grid 2 is empty.
We are trying to drag a row from Grid 1 to Grid 2.
We have this working in another web page, but it seems that within a user control there are complications. When we perform the drag/drop we get this error:
System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Telerik.Web.UI.RadGrid.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) --- End of inner exception stack trace --- at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.review_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\mppr4\4fbd45b7\6039e974\App_Web_r6ddz0kb.20.cs:line 0 at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
function onRowDropping(sender, args) {
debugger;
if (sender.get_id() == "<%=rgArticles.ClientID %>") {
var node = args.get_destinationHtmlElement();
if (!isChildOf('<%=RadGrid1.ClientID %>', node) && !isChildOf('<%=rgArticles.ClientID %>', node)) {
args.set_cancel(true);
}
}
}
function isChildOf(parentId, element) {
while (element) {
if (element.id && element.id.indexOf(parentId) > -1) {
return true;
}
element = element.parentNode;
}
return false;
}

| public class MenuItem |
| { |
| public string Name { get; set; } |
| public List<MenuItem> Items { get; private set; } |
| public MenuItem() |
| { |
| this.Items = new List<MenuItem>(); |
| } |
| } |
public void radGrid_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e){ switch (e.CommandName.ToString()) { case "PerformInsert": { //do something to determine if I can insert a record //if I can not insert a record //How do I close the insert items template?
I've tried e.Cancelled = true; but that doesn't seem to work. At this point, I successfully abort the insert, but the user continues to see the insert controls. She/he has to click the insert template's cancel button to close them.
Thanks!
Here's the grid markup:
<telerik:RadGrid runat="server" ID="rgDashboardGoals" AllowSorting="false" AllowAutomaticDeletes="true" GridLines="None" AllowFilteringByColumn="false" AllowPaging="true" Skin="Outlook" EnableViewState="true" AutoGenerateColumns="false" AllowAutomaticUpdates="true" PageSize="10" AllowMultiRowSelection="True" AllowMultiRowEdit="True" AllowAutomaticInserts="True" OnItemUpdated="rgDashboardGoals_ItemUpdated" OnItemCommand="rgDashboardGoals_ItemCommand" OnPageIndexChanged="rgDashboardGoals_PageChange" OnItemDataBound="rgDashboardGoals_ItemDataBound" StatusBarSettings-LoadingText="Loading..." OnNeedDataSource="LoadDashboardGoalsGrid"> <MasterTableView DataKeyNames="PartsDashboard_id,MonthYear" CommandItemDisplay="Top"> <CommandItemTemplate> <div style="padding: 5px 5px;"> Dashboard Goals grid management tools >> <asp:LinkButton ID="btnEditSelected" runat="server" CommandName="EditSelected" Visible='<%# rgDashboardGoals.EditIndexes.Count == 0 %>'> <img style="border:0px;vertical-align:middle;" alt="" src="../Images/Edit.gif"/>Edit selected </asp:LinkButton> <asp:LinkButton ID="btnUpdateEdited" runat="server" CommandName="UpdateEdited" Visible='<%# rgDashboardGoals.EditIndexes.Count > 0 %>'> <img style="border:0px;vertical-align:middle;" alt="" src="../Images/Update.gif"/>Update </asp:LinkButton> <asp:LinkButton ID="btnCancel" runat="server" CommandName="CancelAll" CausesValidation="false" Visible='<%# rgDashboardGoals.EditIndexes.Count > 0 || rgDashboardGoals.MasterTableView.IsItemInserted %>'> <img style="border:0px;vertical-align:middle;" alt="" src="../Images/Cancel.gif"/>Cancel </asp:LinkButton> <asp:LinkButton ID="LinkButton2" runat="server" CommandName="InitInsert" Visible='<%# !rgDashboardGoals.MasterTableView.IsItemInserted %>'> <img style="border:0px;vertical-align:middle;" alt="" src="../Images/AddNew.gif"/>Add new </asp:LinkButton> <asp:LinkButton ID="LinkButton3" runat="server" CommandName="PerformInsert" Visible='<%# rgDashboardGoals.MasterTableView.IsItemInserted %>'> <img style="border:0px;vertical-align:middle;" alt="" src="../Images/Insert.gif"/> Add this goal record </asp:LinkButton> <asp:LinkButton ID="LinkButton1" OnClientClick="javascript:return confirm('Delete selected goal record(s)?')" runat="server" CommandName="DeleteSelected"> <img style="border:0px;vertical-align:middle;" alt="" src="../Images/deleteRecord.gif"/>Delete selected goal records </asp:LinkButton> <asp:LinkButton ID="LinkButton4" runat="server" CommandName="RebindGrid"> <img style="border:0px;vertical-align:middle;" alt="" src="../Images/refreshGrid.gif"/>Refresh grid </asp:LinkButton> </div> </CommandItemTemplate> <Columns> <telerik:GridBoundColumn ReadOnly="true" UniqueName="Dealer_id" HeaderText="Dealer Code" SortExpression="Dealer_id" DataField="Dealer_id" /> <telerik:GridBoundColumn UniqueName="MonthYear" DataField="MonthYear" ReadOnly="true" HeaderText="Month/Year" SortExpression="MonthYear" /> <telerik:GridTemplateColumn ReadOnly="true" UniqueName="HinoOnlyGoal" SortExpression="HinoOnlyGoal" HeaderText="Hino Only Goal"> <ItemTemplate> <asp:Label ID="lblHinoOnlyGoal" Text='<%# Eval("HinoOnlyGoal").ToString() %>' runat="server" /> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn UniqueName="GoalMonthInsert" EditFormColumnIndex="0" Visible="false" HeaderText="Goal Month"> <InsertItemTemplate> <asp:DropDownList ID="ddlGoalMonth" runat="server" CssClass="hino_text"> <asp:ListItem Text="January" Value="1" /> <asp:ListItem Text="February" Value="2" /> <asp:ListItem Text="March" Value="3" /> <asp:ListItem Text="April" Value="4" /> <asp:ListItem Text="May" Value="5" /> <asp:ListItem Text="June" Value="6" /> <asp:ListItem Text="July" Value="7" /> <asp:ListItem Text="August" Value="8" /> <asp:ListItem Text="September" Value="9" /> <asp:ListItem Text="October" Value="10" /> <asp:ListItem Text="November" Value="11" /> <asp:ListItem Text="December" Value="12" /> </asp:DropDownList> </InsertItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn UniqueName="GoalYearInsert" EditFormColumnIndex="0" Visible="false" HeaderText="Goal Year"> <InsertItemTemplate> <asp:DropDownList ID="ddlGoalYear" runat="server" CssClass="hino_text"> <asp:ListItem Text="2013" Value="2013" /> <asp:ListItem Text="2014" Value="2014" /> <asp:ListItem Text="2015" Value="2015" /> <asp:ListItem Text="2016" Value="2016" /> <asp:ListItem Text="2017" Value="2017" /> <asp:ListItem Text="2018" Value="2018" /> </asp:DropDownList> </InsertItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn UniqueName="HinoOnlyGoalEdit" EditFormColumnIndex="0" Visible="false" HeaderText="Hino Only Goal"> <EditItemTemplate> <asp:TextBox ID="txtHinoOnlyGoal" runat="server" Text='<%# Eval("HinoOnlyGoal").ToString() %>' /> <asp:RequiredFieldValidator ID="rfvHinoOnlyGoal" ControlToValidate="txtHinoOnlyGoal" ErrorMessage="*- Required" runat="server" InitialValue="" /> <asp:RegularExpressionValidator ID="revHinoOnlyGoal" runat="server" ControlToValidate="txtHinoOnlyGoal" ErrorMessage="* - Must be a valid number. " ValidationExpression="[0-9]+(\.[0-9][0-9]?)?" /> </EditItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn ReadOnly="true" UniqueName="AllMakesGoal" SortExpression="AllMakesGoal" HeaderText="All Makes Goal"> <ItemTemplate> <asp:Label ID="lblAllMakesGoal" Text='<%# Eval("AllMakesGoal").ToString() %>' runat="server" /> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn UniqueName="AllMakesGoalEdit" EditFormColumnIndex="0" Visible="false" HeaderText="All Makes Goal"> <EditItemTemplate> <asp:TextBox ID="txtAllMakesGoal" runat="server" Text='<%# Eval("AllMakesGoal").ToString() %>' /> <asp:RequiredFieldValidator ID="rfvAllMakesGoal" ControlToValidate="txtAllMakesGoal" ErrorMessage="*- Required" runat="server" InitialValue="" /> <asp:RegularExpressionValidator ID="revAllMakesGoal" runat="server" ErrorMessage="* - Must be a valid number. " ControlToValidate="txtAllMakesGoal" ValidationExpression="[0-9]+(\.[0-9][0-9]?)?" /> </EditItemTemplate> </telerik:GridTemplateColumn> </Columns> <EditFormSettings ColumnNumber="3"> <FormTableItemStyle Wrap="False"></FormTableItemStyle> <FormCaptionStyle></FormCaptionStyle> <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" Width="100%" /> <FormTableStyle GridLines="Horizontal" CellSpacing="0" CellPadding="2" Height="110px" Width="100%" /> <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle> <FormStyle Width="100%" BackColor="#eef2ea"></FormStyle> <EditColumn UniqueName="EditCommandColumn1" UpdateImageUrl="../Images/order.gif" CancelImageUrl="../Images/cancel.gif" ButtonType="ImageButton" /> <FormTableButtonRowStyle HorizontalAlign="Left"></FormTableButtonRowStyle> </EditFormSettings> </MasterTableView> <ClientSettings EnableRowHoverStyle="true"> <Selecting AllowRowSelect="True" /> </ClientSettings> </telerik:RadGrid>
e.Canceled =
true;
e.Canceled =
true;
e.Canceled =
true;