recuperer l'element selectionnee dans un CascadingDropDown
bonjour, je viens de céer mon CascadingDropDown, et je veux faire une insertion mais je sais pas comment recuperer les valeur de mon dll, j'ai mis toute les possibilité :
ddlCategorie2.SelectedItem.Value
ddlCategorie2.Selectedvalue
mais ca marche pas, il m'insere la veleur null, que dois je faire?
mon dll est remplie a l'aide de la fonction :getCategorie :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| public CascadingDropDownNameValue[] GetCategories(string knownCategoryValues, string category)
{
//Create sql connection and sql command
SqlConnection con = new SqlConnection(strConnection);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = System.Data.CommandType.Text;
cmd.CommandText = "Select * from Categorie";
//Create dataadapter and fill the dataset
SqlDataAdapter dAdapter = new SqlDataAdapter();
dAdapter.SelectCommand = cmd;
con.Open();
DataSet objDs = new DataSet();
dAdapter.Fill(objDs);
con.Close();
//create list and add items in it
//by looping through dataset table
List<CascadingDropDownNameValue> categorieNames
= new List<CascadingDropDownNameValue>();
foreach (DataRow dRow in objDs.Tables[0].Rows)
{
string CategorieID = dRow["idCategorie"].ToString();
string CategorieName = dRow["Categorie"].ToString();
categorieNames.Add(new CascadingDropDownNameValue
(CategorieName, CategorieID));
}
return categorieNames.ToArray();
} |
je veuix recuperer l'element idCategorie selectionnée !