单选按钮选择索引不起作用

时间:2018-06-11 00:23:47

标签: asp.net radiobuttonlist selectedindex

所以我有一个sipme ASP.NET网页,用于打印在单选按钮列表中动态堆叠的一个性别的信息:

$(window).on("beforeunload", function() { 
    return confirm("Do you really want to close?"); 
})

然而,当我启动网站时,无论我选择它,它总是写女性,就像RadioButtonList1.SelectedIndex == 0不起作用。

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

radiobuttonlist page_Load !IsPostBack与[{1}}条件绑定,或者radiobuttonlist每次发帖都会绑定radiobuttonlist。因此,当您点击-1时,button_click会重置为索引 protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { String[] genders = new String[2]; genders[0] = "Male"; genders[1] = "Female"; RadioButtonList1.DataSource = genders; RadioButtonList1.DataBind(); RadioButtonList1.Items.Add(new ListItem("Neutral", "Zero")); } }

# - "-r"
# - "arn:aws:iam::**********:role/**********"