WebServiceSettings and other Parameter

2 posts, 0 answers
  1. hesam
    hesam avatar
    26 posts
    Member since:
    May 2008

    Posted 21 Jan 2009 Link to this post

    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
    1 using System;  
    2 using System.Web;  
    3 using System.Collections;  
    4 using System.Collections.Generic;  
    5 using System.Collections.Specialized;  
    6 using System.Configuration;  
    7 using System.Data;  
    8 using System.Data.SqlClient;  
    9 using System.Threading;  
    10 using System.Web.Script.Services;  
    11 using System.Web.Services;  
    12 using System.Web.Services.Protocols;  
    13 using Telerik.Web.UI;  
    14  
    15 [ScriptService]  
    16 public class TreeContent : WebService   
    17 {  
    18       
    19     [WebMethod]  
    20     public RadTreeNodeData[] GetTreeViewContent(RadTreeNodeData node, object context)  
    21     {  
    22         IDictionary<stringobject> contextDictionary = (IDictionary<stringobject>)context;  
    23         DataTable productCategories = GetNodeContent(node.Value);  
    24  
    25         List<RadTreeNodeData> result = new List<RadTreeNodeData>();  
    26  
    27         foreach (DataRow row in productCategories.Rows)  
    28         {  
    29             RadTreeNodeData itemData = new RadTreeNodeData();  
    30             itemData.Text = row["strMenuName"].ToString();  
    31             itemData.Value = row["MenuId"].ToString();  
    32  
    33             if (Convert.ToInt32(row["ChildrenCount"]) > 0)  
    34             {  
    35                 itemData.ExpandMode = TreeNodeExpandMode.WebService;  
    36             }  
    37             result.Add(itemData);  
    38         }  
    39         return result.ToArray();  
    40     }  
    41       
    42         private DataTable GetNodeContent(object categoryId)  
    43     {  
    44         SqlConnection connection = new SqlConnection(  
    45             ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);  
    46  
    47         SqlCommand selectCommand =  
    48             new SqlCommand(@"
    49     SELECT
    50         pc1.MenuId,
    51         pc1.strMenuName,
    52         ISNULL(pc2.ChildrenCount, 0) as ChildrenCount
    53     FROM Menu as pc1
    54     LEFT JOIN
    55         (
    56             SELECT   intmenuParentId, COUNT(*) AS ChildrenCount
    57             FROM     Menu
    58             Group By (intmenuParentId)
    59         ) as pc2
    60     ON
    61         pc1.MenuId = pc2.intmenuParentId
    62     WHERE pc1.intmenuParentId =@intmenuParentId and pc1.admin=@admin and pc1.content=@content
    63
    64 " 
    65 ,  
    66         connection);  
    67 /*@"
    68     SELECT
    69         pc1.CategoryID,
    70         pc1.Title,
    71         ISNULL(pc2.ChildrenCount, 0) as ChildrenCount
    72     FROM ProductCategories as pc1
    73     LEFT JOIN
    74         (
    75             SELECT   ParentId, COUNT(*) AS ChildrenCount
    76             FROM     ProductCategories
    77             Group By (ParentId)
    78         ) as pc2
    79     ON
    80         pc1.CategoryId = pc2.ParentId
    81     WHERE pc1.parentId = @parentId
    82 "*/ 
    83         selectCommand.Parameters.AddWithValue("intmenuParentId", categoryId);  
    84 /********************************how i can pass parameter *********************************/ 
    85 selectCommand.Parameters.AddWithValue("admin", stradmin);  
    86 selectCommand.Parameters.AddWithValue("content", strcontent);  
    87 /*****************************************************************/ 
    88  
    89         SqlDataAdapter adapter = new SqlDataAdapter(selectCommand); ;  
    90         DataTable productCategories = new DataTable();  
    91         adapter.Fill(productCategories);  
    92         return productCategories;  
    93     }  
    94

    how i can passed "stradmin" and "strcontent" in to webservices
    thanks A lot team
  2. hesam
    hesam avatar
    26 posts
    Member since:
    May 2008

    Posted 21 Jan 2009 Link to this post

    hi
    please help me

    thanks
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top