hi telerik team
how i can bind telerik tree whit WebServiceSettings and passed other parameter that
for example
<telerik:RadTreeView |
ID="RadTreeView1" runat="server" |
Width="100%" SkinID="TreeTelerik" |
LoadingStatusPosition="AfterNodeText" |
> |
<ExpandAnimation Type="InQuad" /> |
<CollapseAnimation Type="InOutBack" /> |
<WebServiceSettings Path="TreeContent.asmx" Method="GetTreeViewContent" /> |
<Nodes> |
<telerik:RadTreeNode Text="root node" Value="0" ExpandMode="WebService" |
Selected="True" /> |
</Nodes> |
</telerik:RadTreeView> |
using System; | |
using System.Web; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Collections.Specialized; | |
using System.Configuration; | |
using System.Data; | |
using System.Data.SqlClient; | |
using System.Threading; | |
using System.Web.Script.Services; | |
using System.Web.Services; | |
using System.Web.Services.Protocols; | |
using Telerik.Web.UI; | |
[ScriptService] | |
public class TreeContent : WebService | |
{ | |
[WebMethod] | |
public RadTreeNodeData[] GetTreeViewContent(RadTreeNodeData node, object context) | |
{ | |
IDictionary<string, object> contextDictionary = (IDictionary<string, object>)context; | |
DataTable productCategories = GetNodeContent(node.Value); | |
List<RadTreeNodeData> result = new List<RadTreeNodeData>(); | |
foreach (DataRow row in productCategories.Rows) | |
{ | |
RadTreeNodeData itemData = new RadTreeNodeData(); | |
itemData.Text = row["strMenuName"].ToString(); | |
itemData.Value = row["MenuId"].ToString(); | |
if (Convert.ToInt32(row["ChildrenCount"]) > 0) | |
{ | |
itemData.ExpandMode = TreeNodeExpandMode.WebService; | |
} | |
result.Add(itemData); | |
} | |
return result.ToArray(); | |
} | |
private DataTable GetNodeContent(object categoryId) | |
{ | |
SqlConnection connection = new SqlConnection( | |
ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); | |
SqlCommand selectCommand = | |
new SqlCommand(@" | |
SELECT | |
pc1.MenuId, | |
pc1.strMenuName, | |
ISNULL(pc2.ChildrenCount, 0) as ChildrenCount | |
FROM Menu as pc1 | |
LEFT JOIN | |
( | |
SELECT intmenuParentId, COUNT(*) AS ChildrenCount | |
FROM Menu | |
Group By (intmenuParentId) | |
) as pc2 | |
ON | |
pc1.MenuId = pc2.intmenuParentId | |
WHERE pc1.intmenuParentId =@intmenuParentId and pc1.admin=@admin and pc1.content=@content | |
" | |
, | |
connection); | |
/*@" | |
SELECT | |
pc1.CategoryID, | |
pc1.Title, | |
ISNULL(pc2.ChildrenCount, 0) as ChildrenCount | |
FROM ProductCategories as pc1 | |
LEFT JOIN | |
( | |
SELECT ParentId, COUNT(*) AS ChildrenCount | |
FROM ProductCategories | |
Group By (ParentId) | |
) as pc2 | |
ON | |
pc1.CategoryId = pc2.ParentId | |
WHERE pc1.parentId = @parentId | |
"*/ | |
selectCommand.Parameters.AddWithValue("intmenuParentId", categoryId); | |
/********************************how i can pass parameter *********************************/ | |
selectCommand.Parameters.AddWithValue("admin", stradmin); | |
selectCommand.Parameters.AddWithValue("content", strcontent); | |
/*****************************************************************/ | |
SqlDataAdapter adapter = new SqlDataAdapter(selectCommand); ; | |
DataTable productCategories = new DataTable(); | |
adapter.Fill(productCategories); | |
return productCategories; | |
} | |
} |
how i can passed "stradmin" and "strcontent" in to webservices
thanks A lot team