2013年9月12日星期四

Drop-down box SelectValue not get value ?

this.ddlState.SelectedValue = CurrentUser.RoleId.ToString ();

commissioning found this.ddlState.SelectedValue does not get value CurrentUser.RoleId.ToString () values ​​are 25
------ Solution ----------- ---------------------------------

you must be first be tied to the value of all given to the drop-down , and then under the corresponding id value appear in the drop in
------ For reference only --------------------- ------------------
this.ddlState.SelectedItem.Text = CurrentUser.RoleId.ToString ();
------ For where reference only ---------------------------------------
executed sentence code, is not a service -side controls causes a page refresh , refresh the drop was
------ For reference only ---------------------- -----------------
can not do this assignment , SelectValue drop-down box to set the value of your useless , generally used to get , if you want the corresponding item is selected , you can with SelectedValue, SelectedItem, SelectedIndex
------ For reference only -------------------------------- -------
see SelectedValue wrong , this is not postpack property you may need to add
------ For reference only ------------------------- --------------


so I drop out of the box is the value of 25 is based on the ID to get my name value
------ For reference only ------------- --------------------------


page loading in the event log based on the ID to the default drop-down box value
------ For reference only ------------------ ---------------------
ddlState.Items.Insert (0, new ListItem (name, id.ToString ()));
------ For reference only -------------------------------------- -


loading event has been added isPostBack the
------ For reference only -------------------------- -------------
! ispostback
------ For reference only -------------------- -------------------
attention to the next page postback is not a ~ ~ ~
------ For reference only ----- ----------------------------------


no effect ah do not know the meaning of this code is not a drop-down box is bound to come out and there is only one value of ?
------ For reference only ------------------------------------ ---
online ah seek expert help but do not know why my other pages also
this.ddlState.SelectedValue = CurrentUser.RoleId.ToString ();
But this page to obtain a new value , but why do I use the phrase on the page is not less than plus access to what ?
------ For reference only -------------------------------------- -
if (! Page.IsPostBack)
{
if (CurrentUser.RoleId.ToString () == "26" | | CurrentUser.RoleId.ToString () == "27" | | CurrentUser.RoleId.ToString () == " 28 " )
{
this.ddlState.SelectedValue = CurrentUser.RoleId.ToString ();
}
if (SiteConfig.RoleIDS == CurrentUser.RoleId . ToString ())
{
btnAdd.Visible = ; true;
btnDel.Visible = ; true;
}
else
{
btnAdd.Visible = ; false;
btnDel.Visible = ; false;
}
if (SiteConfig.AdminRoleID == CurrentUser.RoleId . ToString ())
{
btnAdd.Visible = ; true;
btnDel.Visible = ; true;
}
Pager = PagerConditionFactory.CreateDefaultPagerCondition ();
spBottom.PageSize = Pager.PageSize;

BindListData ();
}
------ For reference only --------- ------------------------------
this.ddlState.Item.Add( CurrentUser.RoleId.ToString());

------ For reference only - -------------------------------------
because I find the reasons for the a successful page drop-down box value which has 262,728 three ID values ​​and my new page value value inside or Chinese so get solved thanks ! ! ! !
------ For reference only -------------------------------------- -
I also can not get the value ! Is the Page_Load event . With DropDownList1.SelectedValue acquisition, the retrieved value is null !

没有评论:

发表评论