I started working a little while with WebForms
and was left in doubt, because I always mess with asp.net mvc
.
Assuming I have a DropDownList
and populated DataSource
with multiple records, when done PostBack
I can not retrieve the data contained in this DropDownList
, is there any way to retrieve this data? what is the best way to work with data in PostBack
. Thank you.
private void PopularEmpresasDoGrupoDoUsuario()
{
VOB2BUser voUser = GetSessionUser();
DAOB2BCompany daoCompany = new DAOB2BCompany(((Page)Page).DATABASE);
DAOB2BUser daoUser = new DAOB2BUser(((Page)Page).DATABASE);
DAOB2BCompanyGroupUser daoCompanyGroupUser = new DAOB2BCompanyGroupUser(((Page)Page).DATABASE);
var userGroup = daoCompanyGroupUser.GetUserGroup(voUser.IdUser);
if (userGroup == null)
{
divEmpresasDoGrupoDoUsuario.Visible = false;
}
else
{
divEmpresasDoGrupoDoUsuario.Visible = true;
dropDownListEmpresasDoGrupoDoUsuario.DataSource = daoCompany.GetEmpresasVinculadasNoGrupoDeEmpresa(userGroup.IdGroup);
dropDownListEmpresasDoGrupoDoUsuario.DataBind();
upEmpresasDoGrupoDoUsuario.Update();
dropDownListEmpresasDoGrupoDoUsuario.SelectedIndex = 0;
dropDownListEmpresasDoGrupoDoUsuario_SelectedIndexChanged(dropDownListEmpresasDoGrupoDoUsuario, new EventArgs());
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.IsPostBack)
{
if (Session["USER"] != null)
{
PopularEmpresasDoGrupoDoUsuario();
SetUserPermissions(fc);
}
}
}