PDA

View Full Version : شمارش گزینه های زده شده



qazxsw
شنبه 31 مرداد 1388, 13:12 عصر
سلام من یه page دارم مربوط به نمایش سوالات چهار گزینه ای وقتی میخام گزینه های زده شده توسط کاربر رو بشمارم خطای زیر رو نمایش میده
اینم اون خطی که ازش ایراد میگیره مشکل از چی میتونه باشه

;(x = dlquest.Items[i].FindControl("rb" + j
----------------------------------------
CS0266: Cannot implicitly convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.RadioButton'. An explicit conversion exists (are you missing a cast?)
----------------------------------------






code:
protected void btn_save_Click(object sender, EventArgs e)
{
///''''''''''''''''''''''' find radiobuttonlist_selected ''''''''''''''''''''''''''''''''''''''''
int i;
int j;
RadioButton x = new RadioButton();
for (i = 0; i <= dlquest.Items.Count - 1; i++)
{
for (j = 0; j <= 3; j++)
{
x = datalistquest.Items[i].FindControl("rb" + j);
if (x.Checked == true)
{
break;
}
}
if (x.Checked == true)
{
cheek_question(int.Parse(x.GroupName), j);
}
update_count_quest(int.Parse(x.GroupName));
insert_query(int.Parse(x.GroupName), j);
}
int trueans = System.Convert.ToInt32(ViewState["true"]);
int falseans = System.Convert.ToInt32(ViewState["false"]);
int nonans = datalistquest.Items.Count - (trueans + falseans);
float persent;
persent = (((3 * trueans) - falseans) / (datalistquest.Items.Count * 3)) * 100;
Session["true_ans"] = trueans;
Session["false_ans"] = falseans;
Session["non_ans"] = nonans;
Session["persent"] = persent;

aynehband
شنبه 31 مرداد 1388, 13:44 عصر
فکر کنم باید اینجور اصلاحش کنی




;(x = (RadioButton)dlquest.Items[i].FindControl("rb" + j