internal static void FillDropDown(DropDownList ddlObject, string FieldName)
{
SPWeb oWeb = null;
SPFieldChoice oFieldAccessReq = null;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
try
{
oWeb = SPContext.Current.Web;
foreach (SPList oList in oWeb.Lists)
{
oFieldAccessReq = (SPFieldChoice)oList.Fields[FieldName];
ddlObject.Items.Add(new ListItem(""));
foreach (String strChoice in oFieldAccessReq.Choices)
{
ddlObject.Items.Add(new ListItem(strChoice));
}
}
}
catch (Exception ex)
{
LogError(ex);// You have to write this function.
}
finally
{
if (oWeb != null)
oWeb.Dispose();
}
});
}