troubleshooting Question

USING AJAX CASCADINGDROPDOWN AND WEBSERVICE

Avatar of edwbear1976a
edwbear1976a asked on
ASP.NET
22 Comments1 Solution2168 ViewsLast Modified:
Hi , I'm new in Ajax and I want to use Ajax CascadingDropDown with a database but it requieres webservices besides other stuffs  in the sample they call and handle the Database in the same webservice this but I'm used to DAO files to handle the database and in the webservice code I just call the DAO file and it retrieves me an arraylist of entities so I don't have to use the DataRows stuffe..here is the question: is that right? . If so it might decrease the performance?
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Walkthrough/CCDWithDB.aspx
[WebMethod]
    public CascadingDropDownNameValue[] GetOrdersByEmployee(
      string knownCategoryValues,
      string category)
    {
        StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
        int iEmployee;
        if (!kv.ContainsKey("Employee") || !Int32.TryParse(kv["Employee"], out iEmployee))
        {
            return null;
        }

        SqlConnection connection = new
            SqlConnection(@"Data Source=SERVER\SQLEXPRESS;
                Initial Catalog=Northwind;
                Integrated Security=True");

        SqlCommand command =
            new SqlCommand("SELECT OrderID FROM Orders WHERE EmployeeID = " + iEmployee);

        command.Connection = connection;
        connection.Open();

        SqlDataAdapter adapter = new SqlDataAdapter(command);
        DataSet dataSet = new DataSet();

        adapter.Fill(dataSet);
        command.Connection.Close();

        DataTable tbl = dataSet.Tables[0];

        List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();
        foreach (DataRow dr in tbl.Rows)
        {
            string sOrder = dr["OrderID"].ToString();
            int iOrder = (int)dr["OrderID"];
            values.Add(new CascadingDropDownNameValue(
              sOrder, iOrder.ToString()));
        }
        return values.ToArray();
    }
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 22 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 22 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros