Hello!
I'm having a problem while trying to get the selected Item from a RadListBox...
When i use the RadListBox1.SelectedItem.Value the value is allways null when i use a dictionary as my datasource, but the RadList has 26 rows....However i have other 2 listboxs whose datasource is an entity..i d'ont have any problem....
Here is my code:
I'm having a problem while trying to get the selected Item from a RadListBox...
When i use the RadListBox1.SelectedItem.Value the value is allways null when i use a dictionary as my datasource, but the RadList has 26 rows....However i have other 2 listboxs whose datasource is an entity..i d'ont have any problem....
Here is my code:
public partial class AssignInvoices : Microsoft.Practices.CompositeWeb.Web.UI.Page, IAssignInvoicesView
{
private AssignInvoicesPresenter _presenter;
//implemantaƧao da propriedade
public System.Collections.Generic.IList<
Data.Users
> Users
{
get;
set;
}
public System.Collections.Generic.IList<
Data.Priorities
> Priorities
{
get;
set;
}
public System.Collections.Generic.IList<
Data.Staging
> Staging
{
get;
set;
}
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this._presenter.OnViewInitialized();
}
this._presenter.OnViewLoaded();
Info x = new Info("xx", "xx", "xx,DC=xx,DC=xx");
Dictionary<
string
, string> networkUser = new Dictionary<
string
, string>();
networkUser = x.GetHierarchyTree("xx");
Dictionary<
string
, string> aux = new Dictionary<
string
, string>();
foreach (KeyValuePair<
string
, string> kvp in networkUser)
{
//kvp.Key = user de rede
string userCompName = x.GetUserInfo("cn", kvp.Key);
aux.Add(kvp.Key, userCompName);//Dictionary com key = user de rede e Value = nomeCompleto Utilizador
}
RadListBox1.DataTextField = "Key";
RadListBox1.DataValueField = "Value";
RadListBox1.DataSource = aux;
RadListBox1.DataBind();
//Page.User.Identity.Name para ir buscar o login user
//Popular dados na listbox users
//RadListBox1.DataSource = this.Users;
//RadListBox1.DataTextField = "UserName";
//RadListBox1.DataValueField = "UserSap";
//RadListBox1.DataBind();
//Popular dados na listbox grupos
RadListBox2.DataSource = this.Priorities;
RadListBox2.DataTextField = "Priority";
RadListBox2.DataValueField = "Priority";
RadListBox2.DataBind();
//Popular dados na listbox stagins
RadListBox3.DataSource = this.Staging;
RadListBox3.DataTextField = "Process";
RadListBox3.DataValueField = "Process";
RadListBox3.DataBind();
}
[CreateNew]
public AssignInvoicesPresenter Presenter
{
get
{
return this._presenter;
}
set
{
if (value == null)
throw new ArgumentNullException("value");
this._presenter = value;
this._presenter.View = this;
}
}
// TODO: Forward events to the presenter and show state to the user.
// For examples of this, see the View-Presenter (with Application Controller) QuickStart:
//
protected void RadButton1_Click(object sender, EventArgs e)
{
string _UserValue = RadListBox1.SelectedItem.Value; //Gets the value of item in Users.
//string _text = RadListBox1.SelectedItem.Text; //Gets the Text of items in the list.
List<
string
> _groups = new List<
string
>(); //create a list to store selected groups
string _stg = RadListBox3.SelectedItem.Value; // create a list to store selected stagings
if (RadListBox1.SelectedIndex > -1 && RadListBox2.SelectedIndex > -1 && RadListBox3.SelectedIndex > -1)
{
iConnect.InvoicesScaling.Data.UsersAssignDAO usrAssgnDAO = new iConnect.InvoicesScaling.Data.UsersAssignDAO(new EscalonamentoFacturasEntities());
UsersAssign user = new UsersAssign();
foreach (var grp in RadListBox2.SelectedItems)
{
_groups.Add(grp.Value); //store the selectItems on RadListBox2 to list groups
//efectuar aqui o insert
user.InserDate = DateTime.Now;
int j;
Int32.TryParse(grp.Value, out j);
user.UserName = _UserValue;
user.Priority = j;
user.Staging = _stg;
//passar o objecto a inserir na tabela da bd
usrAssgnDAO.Add(user);
usrAssgnDAO.SaveChanges();
}
}
//else if(RadListBox2.SelectedIndex < -1 )
//reportar erro
}
}
}