Hi,
I am trying to use the Telerik RadListView Darg-Drop feature:
http://demos.telerik.com/aspnet-ajax/listview/examples/datagrouping/defaultcs.aspx
I want to be able to drag an item from one data group to another datagroup. How can I do that?
ASPX code:
C# Code:
I am trying to use the Telerik RadListView Darg-Drop feature:
http://demos.telerik.com/aspnet-ajax/listview/examples/datagrouping/defaultcs.aspx
I want to be able to drag an item from one data group to another datagroup. How can I do that?
ASPX code:
<telerik:RadListView runat="server" ID="Lsv_Vis" AllowPaging="True" PageSize="50" ItemPlaceholderID="Phi_Vis_I" GroupPlaceholderID="Phi_Vis_G" DataKeyNames="url_id, lst_id, url_name, url_address" ClientDataKeyNames="url_id, lst_id, url_name, url_address" OnItemDrop="CsVisItemDrop" OnItemDataBound="CsVisIDB" DataSourceID="Sql_Vis"></telerik:RadListView><DataGroups> <telerik:ListViewDataGroup GroupField="lst_id" DataGroupPlaceholderID="Phi_Vis_G"> <DataGroupTemplate> <div class="Div_Vis_Grp"><span class="Spn_Vis"><%# (Container as RadListViewDataGroupItem).AggregatesValues["lst_name"].ToString() %></span></div> <asp:Panel ID="Pnl_Vis" runat="server" CssClass="Pnl_Vis" ToolTip='<%# (Container as RadListViewDataGroupItem).DataGroupKey %>' onmouseover='this.className += " Vis_Sel";' onmouseout='this.className = this.className.split(" Vis_Sel").join("");'> <asp:PlaceHolder ID="Phi_Vis_I" runat="server" /> </asp:Panel> </DataGroupTemplate> <GroupAggregates> <telerik:ListViewDataGroupAggregate Aggregate="Max" DataField="lst_name" /> </GroupAggregates> </telerik:ListViewDataGroup></DataGroups><ItemTemplate> <div class="Div_Vis_Item rlvI"> <asp:Panel ID="Pnl_Vis" runat="server" ToolTip='<%# Eval("lst_id") %>' CssClass="Div_Vis_Item" onmouseover='this.className += " Vis_Sel";' onmouseout='this.className = this.className.split(" Vis_Sel").join("");'> <a class="Hyp_Vis" runat="server" href='<%# Eval("url_address") %>' target="_blank"> <div class="Div_Vis_Body"> <div class="Div_Vis_Con"> <asp:Panel ID="Div_Vis_Con" runat="server" class="Div_Vis_Con" ToolTip='<%# Eval("lst_id") %>' ></asp:Panel> </div> </div> <div class="Div_Vis_Link"> <asp:Label ID="Lbl_VisI" runat="server" Text='<%# Eval("url_name_short") %>' ToolTip='<%# Eval("url_name") %>'/> </div> </a> </asp:Panel> </div></ItemTemplate>C# Code:
protected void CsVisItemDrop(object sender, RadListViewItemDragDropEventArgs e){ if (e.DestinationHtmlElement.IndexOf("Div_Vis_Con") < 0) { return; } foreach (RadListViewDataItem di in Lsv_Vis.Items) { Panel pnl = di.FindControl("Div_Vis_Con") as Panel; if (pnl != null && pnl.ClientID == e.DestinationHtmlElement) { string uid = e.DraggedItem.GetDataKeyValue("url_id").ToString(); string lid = pnl.ToolTip.ToString(); using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Con_Str"].ToString())) { using (SqlCommand cmd = new SqlCommand("UPDATE [MyTable] SET lst_id = @lst_id WHERE url_id = @url_id", conn)) { cmd.Parameters.Add("@lst_id", SqlDbType.VarChar).Value = lid; cmd.Parameters.Add("@url_id", SqlDbType.VarChar).Value = uid; try { conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); } catch { } } } } } Lsv_Vis.Rebind();}