Hello guys,
I am using the approach to be able to iterate through the textboxes and dropdow list on a page
public static IEnumerableGetAllControls(Control parent)
{
if(null == parent) return null;
return new Control[] { parent }.Union(parent.Controls.OfType().SelectMany(child => GetAllControls(child));
}
foreach(DropDownList list in GetAllControls(this).OfType())
{
//TODO: add values to dictionary collections and append to session object
}
Now, after the loop and getting the values, I need to be able to store the droplist list ids and values into a sesion to be available elsewhere in the application.
Please help.
Thanks
untested, but something like
Dictionarydata = new Dictionary ();
foreach(DropDownList list in GetAllControls(this).OfType())
{
data.Add (list.ID, list.Items);
}
Session["DropDownData"] = data;
沒有留言:
張貼留言