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

Webservice Call For RadTreeView

5 Answers 132 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Sunil
Top achievements
Rank 1
Sunil asked on 29 Jul 2008, 07:30 AM

  I am getting an error stating that The server method 'MethodName' Failed error when I am expanding the tree view. I am following the example which is given under telerik for the webservice. I am also unable to get the cursor to the debug point which I placed at the start of the webmethod in web service.

5 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 29 Jul 2008, 07:41 AM
Hello Sunil,

You have probably not applied the [System.Web.Script.Services.ScriptService] attribute to your web service.

Kind regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Sunil
Top achievements
Rank 1
answered on 29 Jul 2008, 08:15 AM
Hai Albert ,

 I have put it. Still it is not working
0
Atanas Korchev
Telerik team
answered on 29 Jul 2008, 08:18 AM
Hi Sunil,

Please check our WebService example. The code of the web service is located in App_Code\ProductCategories.cs. Here is an excerpt from it:

[ScriptService] 
public class ProductCategories : WebService 
    [WebMethod] 
    public RadTreeNodeData[] GetTreeViewCategories(RadTreeNodeData node, object context) 
    { 
        DataTable productCategories = GetProductCategories(node.Value); 
 
        List<RadTreeNodeData> result = new List<RadTreeNodeData>(); 
 
        foreach (DataRow row in productCategories.Rows) 
        { 
            RadTreeNodeData itemData = new RadTreeNodeData(); 
            itemData.Text = row["Title"].ToString(); 
            itemData.Value = row["CategoryId"].ToString(); 
 
            if (Convert.ToInt32(row["ChildrenCount"]) > 0) 
            { 
                itemData.ExpandMode = TreeNodeExpandMode.WebService; 
            } 
 
            result.Add(itemData); 
        } 
 
        return result.ToArray(); 
    } 
 
    private DataTable GetProductCategories(object categoryId) 
    { 
        SqlConnection connection = new SqlConnection( 
            ConfigurationManager.ConnectionStrings["TelerikConnectionString"].ConnectionString); 
 
        SqlCommand selectCommand = 
            new SqlCommand( 
@"
    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
"
        connection); 
 
        selectCommand.Parameters.AddWithValue("parentId", categoryId); 
 
        SqlDataAdapter adapter = new SqlDataAdapter(selectCommand); ; 
 
        DataTable productCategories = new DataTable(); 
        adapter.Fill(productCategories); 
 
        return productCategories; 
    } 


Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Sunil
Top achievements
Rank 1
answered on 29 Jul 2008, 08:26 AM

Hai Albert ,

  I am using the same code except the code from retriving from the database because I have to use my own tables. Till yesterday it is worked fine.Yesterday I updated rad controls to Q1 2008 release in order to put automatic text-wrapping  for the chart. After that I am facing the problem with respect to the tree view control.
Following lines represents my web.config.

<

add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />

<

add path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI" validate="false" />

<

add path="ChartImage.axd" verb="*" type="Telerik.Web.UI.ChartHttpHandler, Telerik.Web.UI, Version=2008.2.723.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4" validate="false" />

 

0
Atanas Korchev
Telerik team
answered on 29 Jul 2008, 08:32 AM
Hi Sunil,

There should be no change in the way RadTreeView works with web services. Also our online example seems to work as expected. Does the online example work on your side? Have you tried installing the demos on your PC to see if the web service example works?

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
TreeView
Asked by
Sunil
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Sunil
Top achievements
Rank 1
Share this question
or