Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何向RadioButtonList添加值_C#_Asp.net - Fatal编程技术网

C# 如何向RadioButtonList添加值

C# 如何向RadioButtonList添加值,c#,asp.net,C#,Asp.net,有人能告诉我如何在错误答案上加0,在正确答案上加1吗 protected void Page_Load(object sender, EventArgs e) { //Question lblQuestion1.Text = "Which of the following is not a country in Europe?"; //Answers lstAns1.Items.Add("Enland"); lstAns1.Items.Add("G

有人能告诉我如何在错误答案上加0,在正确答案上加1吗

protected void Page_Load(object sender, EventArgs e)
{   
    //Question
    lblQuestion1.Text = "Which of the following is not a country in Europe?";

    //Answers
    lstAns1.Items.Add("Enland");
    lstAns1.Items.Add("Germany");
    lstAns1.Items.Add("France");
    lstAns1.Items.Add("Canada");
}
我想你可以添加,而不仅仅是文本

protected void Page_Load(object sender, EventArgs e)
{   
    if (!Page.IsPostBack)
    {
        //Question
        lblQuestion1.Text = "Which of the following is not a country in Europe?";

        //Answers
        lstAns1.Items.Add(new ListItem("Enland", "0"));
        lstAns1.Items.Add(new ListItem("Germany", "0"));
        lstAns1.Items.Add(new ListItem("France", "0"));
        lstAns1.Items.Add(new ListItem("Canada", "1"));
    }
}
我已经添加了一个检查,检查这个页面是通过HTTP Get还是通过HTTP Post加载的(请参阅:)


无论如何-这段代码是完全静态的。。。。您可以再仔细考虑一下。

请解释您想在哪里添加值0或1?如果可能,我想在页面加载事件中全部添加值您的问题不清楚。请给出一些示例输出。了解您的问题会很有帮助。我想您需要另一列,为每个项目存储
0
1
的值!我认为正确吗?