在asp.net c中面对radiobuttonlist中不可预测的问题# [英] facing unpredictable problem in radiobuttonlist in asp.net c#
问题描述
I,
<div>
<asp:RadioButtonList ID="rdbtnlist" runat="server" TextAlign="Right" OnSelectedIndexChanged="rdb_caltotalval" AutoPostBack="true" RepeatDirection="Vertical" RepeatColumns="1">
</asp:RadioButtonList>
</div>
II,
Bind进入radiobutton列表,
II,
Binding onto radiobutton list,
rdwithoutlogin.DataSource = dtservices;
rdwithoutlogin.DataTextField="descript";
rdwithoutlogin.DataBind();
绑定后,我得到了这样的清单。
UPS NEXT Day Air($ 11.00)
UPS UPS 3天选择($ 30.00)
UPS地面($ 12.03)
FIRST OVERNIGHT($ 65.13)
标准过夜($ 18.03)
FEDEX 2天上午($ 20)
FEDEX 2天($ 30)
FEDEX EXPRESS SAVER($ 13.02)
地面送货($ 30.00)
这里有问题,如果我从列表中选择第三个UPS Ground($ 12.03),但是在循环中第一个被选中,我的意思是,
UPS NEXT Day Air($ 11.00)变为真实而不是UPS Ground($ 12.03) -----------------> item.selected.remaining list为false。我不知道它是怎么发生的那样..
注意:在渲染页面之前,我没有写任何代码来标记在代码后面选择的第一个代码。
并且,OnSelectedIndexChanged =rdb_caltotalval仅在第一次触发时,当我选择第二次时,OnSelectedIndexChanged =rdb_caltotalval事件未被触发。
After binding , i got list like that.
UPS NEXT Day Air($11.00)
UPS UPS 3 Day Select($30.00)
UPS Ground($12.03)
FIRST OVERNIGHT($65.13)
STANDARD OVERNIGHT($18.03)
FEDEX 2 DAY AM($20)
FEDEX 2 DAY($30)
FEDEX EXPRESS SAVER($13.02)
GROUND HOME DELIVERY($30.00)
here is the problem, if i choose third one from list that is "UPS Ground($12.03)", but in loop first one got selected , i mean,
UPS NEXT Day Air($11.00) became true instead of UPS Ground($12.03) ----------------->item.selected.remaining list is false. i do not know how it is happening like that..
note: i did not write any code to mark first one to be selected in code behind before render the page.
And, OnSelectedIndexChanged="rdb_caltotalval" is firing at first time only, when i choose second time, OnSelectedIndexChanged="rdb_caltotalval" event is not fired.
protected void rdb_caltotalval(object sender, EventArgs e)
{
foreach (ListItem item in rdwithoutlogin.Items)
{
if (item.Selected)
{
string s6 = item.Text;
}
}
}
需要帮助。
Help needed.
推荐答案
11.00)
UPS UPS 3天选择(
11.00)
UPS UPS 3 Day Select(
30.00)
UPS Ground(
30.00)
UPS Ground(
12.03)
FIRST OVERNIGHT(
12.03)
FIRST OVERNIGHT(
这篇关于在asp.net c中面对radiobuttonlist中不可预测的问题#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!