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.ParseKno
wnCategory
ValuesStri
ng(knownCa
tegoryValu
es);
int iEmployee;
if (!kv.ContainsKey("Employee
") || !Int32.TryParse(kv["Employ
ee"], 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<CascadingDropDownName
Value> values = new List<CascadingDropDownName
Value>();
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();
}
Bob