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

WebServiceSettings and other Parameter

1 Answer 119 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
hesam
Top achievements
Rank 1
hesam asked on 21 Jan 2009, 01:45 PM

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> 
and webservice
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<stringobject> contextDictionary = (IDictionary<stringobject>)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

1 Answer, 1 is accepted

Sort by
0
hesam
Top achievements
Rank 1
answered on 21 Jan 2009, 09:52 PM
hi
please help me

thanks
Tags
TreeView
Asked by
hesam
Top achievements
Rank 1
Answers by
hesam
Top achievements
Rank 1
Share this question
or