Hi Team,
Drag and Drop control is not working it is throwing error message because of e.DestDataItem is null in the RowDrop event. The radgrid is inside the user control and the user control is added dynamically to the page.
Please provide the possible solution.
Thank You
Main Page :
-----------------
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" BackColor="white" CssClass="radLoadingPanel" Transparency="25">
<h1>Proof Generation in Process...</h1>
</telerik:RadAjaxLoadingPanel>
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
<asp:Panel ID="pnlVariables" runat="server">
</asp:Panel>
<div class="clear">
</div>
<div class="clear">
<asp:Label ID="lblNoOptions" runat="server" CssClass="errorMessage" Visible="False"></asp:Label><br />
<asp:Label ID="lblErrorMessage" runat="server" CssClass="errorMessage" Visible="False"></asp:Label>
</div>
<asp:Panel ID="pnlButton" runat="server">
<label id="lblProcessTimeWarning" runat="server" style="display: block; margin-bottom: 10px;" visible="false">
</label>
<asp:Button ID="btnCreateProofs" runat="server" Text="Save" />
</asp:Panel>
</telerik:RadAjaxPanel>
Main Page code Behind
-------------------------------
Dim tuc As Modules_Controls_BookBuilderControl = CType(LoadControl("~/Modules/Controls/BookBuilderControl.ascx"), Modules_Controls_BookBuilderControl)
tuc.ID = oRow("FriendlyName").ToString()
tuc.CartID = CType(oRow("CartID"), Long)
pnlVariables.Controls.Add(tuc)
Usercontrol.ascx
----------------------
<telerik:RadGrid ID="Parts" runat="server" ClientIDMode="AutoID" AllowPaging="True" AllowSorting="True" ClientSettings-AllowAutoScrollOnDragDrop="true"
AutoGenerateColumns="False" GridLines="None" ShowStatusBar="True" CssClass="Parts" ClientSettings-AllowDragToGroup="true" ClientSettings-AllowRowsDragDrop="true">
<ClientSettings AllowRowsDragDrop="True" AllowColumnsReorder="true" ReorderColumnsOnClient="true">
<Selecting AllowRowSelect="True" EnableDragToSelectRows="false"></Selecting>
<ClientEvents OnBatchEditOpening="batchEditOpening"></ClientEvents>
<Scrolling AllowScroll="true" UseStaticHeaders="true"></Scrolling>
</ClientSettings>
<MasterTableView Name="PartsTableView" ClientIDMode="AutoID" DataKeyNames="InventoryID" AllowSorting="True" NoDetailRecordsText="No Items" HierarchyLoadMode="ServerBind"
NoMasterRecordsText="No Items Added" CommandItemDisplay="Bottom" EditMode="Batch">
<CommandItemSettings ShowAddNewRecordButton="false" ShowCancelChangesButton="false" ShowRefreshButton="false"/>
<BatchEditingSettings EditType="Cell" />
<DetailTables>
<telerik:GridTableView Name="ComponentDetails" Caption="Component Details" DataKeyNames="InventoryID"
runat="server">
<ParentTableRelation>
<telerik:GridRelationFields DetailKeyField="ParentID" MasterKeyField="InventoryID" />
</ParentTableRelation>
<Columns>
<telerik:GridTemplateColumn UniqueName="ThumbNail">
<ItemTemplate>
<asp:Image ID="imgThumbNail" runat="server" ImageUrl='<%#Eval("Thumbnail")%>' />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="ParentID" Display="false" UniqueName="ParentID" />
<telerik:GridBoundColumn DataField="InventoryID" Display="false" UniqueName="InventoryID" />
<telerik:GridBoundColumn DataField="FormNumber" HeaderText="Product Code" UniqueName="FormNumber" />
<telerik:GridBoundColumn DataField="Description" HeaderText="Title" ReadOnly="true"
UniqueName="Description" Display="True" />
</Columns>
</telerik:GridTableView>
</DetailTables>
<Columns>
<telerik:GridTemplateColumn UniqueName="ThumbNail">
<ItemTemplate>
<asp:Image ID="imgThumbNail" runat="server" ImageUrl='<%#Eval("ImageUrl")%>' />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="InventoryID" UniqueName="FormNumber" Display="false" />
<telerik:GridBoundColumn DataField="Text" ItemStyle-Width="150px" HeaderText="Product Code" />
<telerik:GridBoundColumn DataField="Description" HeaderText="Title" Display="true" />
<telerik:GridBoundColumn DataField="Type" Display="false" />
<telerik:GridButtonColumn ButtonType="LinkButton"
CommandName="DeleteInventory" Text="Remove" UniqueName="Delete">
<ItemStyle HorizontalAlign="Center" CssClass="buttonContainer"></ItemStyle>
<HeaderStyle ></HeaderStyle>
</telerik:GridButtonColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
<asp:XmlDataSource ID="XMLBookBuilderSource" runat="server" EnableCaching="false">
</asp:XmlDataSource>
UserControl Code Behind
--------------------------------------
Protected Sub Parts_RowDrop(sender As Object, e As GridDragDropEventArgs) Handles Parts.RowDrop
Try
Dim element As XElement
Dim root As New XElement("BookBuilder")
element = XMLDoc.Root.Elements("Node")(e.DraggedItems(0).ItemIndex)
XMLDoc.Root.Elements("Node")(e.DraggedItems(0).ItemIndex).Remove()
If (XMLDoc.Root.Elements("Node").Count = e.DestDataItem.ItemIndex) Then
XMLDoc.Root.Elements("Node")(e.DestDataItem.ItemIndex - 1).AddBeforeSelf(element)
Else
XMLDoc.Root.Elements("Node")(e.DestDataItem.ItemIndex).AddBeforeSelf(element)
End If
Session("XMLDoc") = XMLDoc
Parts.Rebind()
Catch ex As Exception
WriteLog4Net("Unable to Drag and Drop:: ", ex)
End Try
End Sub