当前位置:编程学习 > C#/ASP.NET >>

在GridView中取RadioButtonList值时候 提示 输入字符串格式不正确

 protected void btnSubmit_Click(object sender, EventArgs e)
    {

        DateTime now = System.DateTime.Now;

        for (int i = 0; i < this.GridView1.Rows.Count; i++)
        {
            if (GridView1.Rows[i].RowType == DataControlRowType.DataRow)
            {
                RadioButtonList rbl = this.GridView1.Rows[i].Cells[0].FindControl("rblOptionList") as RadioButtonList;
                //option.QuestionId = Convert.ToInt32(this.gvQuestionList.DataKeys[e.Row.RowIndex].Value);
                //string s = rbl.SelectedItem.Text;
                vote.OptionId = Convert.ToInt32(rbl.SelectedValue);//输入字符串格式不正确
                vote.AddedDate = now;
                vote.UserIP = HttpContext.Current.Request.UserHostAddress;
                vote.Save();
                question.QuestionId = Convert.ToInt32(this.GridView1.DataKeys[i].Value);
                question.UpdateVoteNum();
            }

        }

        WebHelper.Alert("投票成功");
    }
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,