string examTypeWill = ds.Tables["student"].Rows[0]["examTypeWill"].ToString();
RadioButton rbtnLiKe = new RadioButton();
rbtnLiKe = (RadioButton)(e.Row.Cells[2].FindControl("rbtnLiKe"));
rbtnLiKe.Checked = false;
RadioButton rbtnWenKe = new RadioButton();
rbtnWenKe = (RadioButton)(e.Row.Cells[2].FindControl("rbtnWenKe"));
rbtnWenKe.Checked = false;
RadioButton rbtnTeChang = new RadioButton();
rbtnTeChang = (RadioButton)(e.Row.Cells[2].FindControl("rbtnTeChang"));
rbtnTeChang.Checked = false;
if (examTypeWill == "理科")
{
rbtnLiKe.Checked = true;
rbtnLiKe.ForeColor = Color.Red;
}
else if (examTypeWill == "文科")
{
rbtnWenKe.Checked = true;
rbtnWenKe.ForeColor = Color.Red;
}
else if (examTypeWill == "特长")
{
rbtnTeChang.Checked = true;
rbtnTeChang.ForeColor = Color.Red;
}
帮我看看为什么不能赋值啊, 我快疯掉了,马上要要的.....
RadioButton rbtnLiKe = new RadioButton();
rbtnLiKe = (RadioButton)(e.Row.Cells[2].FindControl("rbtnLiKe"));
rbtnLiKe.Checked = false;
RadioButton rbtnWenKe = new RadioButton();
rbtnWenKe = (RadioButton)(e.Row.Cells[2].FindControl("rbtnWenKe"));
rbtnWenKe.Checked = false;
RadioButton rbtnTeChang = new RadioButton();
rbtnTeChang = (RadioButton)(e.Row.Cells[2].FindControl("rbtnTeChang"));
rbtnTeChang.Checked = false;
if (examTypeWill == "理科")
{
rbtnLiKe.Checked = true;
rbtnLiKe.ForeColor = Color.Red;
}
else if (examTypeWill == "文科")
{
rbtnWenKe.Checked = true;
rbtnWenKe.ForeColor = Color.Red;
}
else if (examTypeWill == "特长")
{
rbtnTeChang.Checked = true;
rbtnTeChang.ForeColor = Color.Red;
}
帮我看看为什么不能赋值啊, 我快疯掉了,马上要要的.....
解决方案 »
- 关于cache保存大数据量的问题
- listview固定列宽
- word中图片导入数据库的问题。。。请教大家。。。解决还可以加分。八百里加急呀。。
- dropdownlist 和textbox联动 textbox为大类,dropdownlist为小类
- 问一个有关split的问题,忘大家帮忙
- 求救!!局域网内两台电脑怎样相互访问?
- window.open问题,高手进来!!!!!!!!!!!!!
- 求教网站后台的短信设置怎么做
- .NET连接MYSQL的问题.
- 关于使用VS.NET建立ASP.NET WEB 应用程序的问题…
- 关于ASP.NET的身份验证
- 关于VS2005中Datalist里放了RadioBottonList的绑定问题
rbtnLiKe = (RadioButton)(e.Row.Cells[2].FindControl("rbtnLiKe"));
==>
RadioButton rbtnLike=(RadioButton)(e.Row.Cells[2].FindControl("rbtnLiKe"));试试??
Message="未将对象引用设置到对象的实例。"
if(e.item.itemindex>=0)
{
string examTypeWill = ds.Tables["student"].Rows[0]["examTypeWill"].ToString();
RadioButton rbtnLiKe = (RadioButton)(e.Row.Cells[2].FindControl("rbtnLiKe"));
rbtnLiKe.Checked = false;
RadioButton rbtnWenKe = (RadioButton)(e.Row.Cells[2].FindControl("rbtnWenKe"));
rbtnWenKe.Checked = false;
RadioButton rbtnTeChang = (RadioButton)(e.Row.Cells[2].FindControl("rbtnTeChang"));
rbtnTeChang.Checked = false;
if (examTypeWill == "理科")
{
rbtnLiKe.Checked = true;
rbtnLiKe.ForeColor = Color.Red;
}
else if (examTypeWill == "文科")
{
rbtnWenKe.Checked = true;
rbtnWenKe.ForeColor = Color.Red;
}
else if (examTypeWill == "特长")
{
rbtnTeChang.Checked = true;
rbtnTeChang.ForeColor = Color.Red;
}
}
{
string examTypeWill = null;
stuSchoolID = this.gvStudent.Rows[i].Cells[0].Text.ToString();
RadioButton rbtnLiKe = (RadioButton)(this.gvStudent.Rows[i].Cells[2].FindControl("rbtnLiKe"));
RadioButton rbtnWenKe = (RadioButton)(this.gvStudent.Rows[i].Cells[2].FindControl("rbtnWenKe"));
RadioButton rbtnTeChang = (RadioButton)(this.gvStudent.Rows[i].Cells[2].FindControl("rbtnTeChang"));
try
{
if (rbtnLiKe.Checked == true)
{
examTypeWill = "理科";
}
else if (rbtnWenKe.Checked == true)
{
examTypeWill = "文科";
}
else if (rbtnTeChang.Checked == true)
{
examTypeWill = "特长";
}
cmd.CommandText = "update student set examTypeWill='" + examTypeWill + "' where stuSchoolID='" + stuSchoolID + "'";
if (cmd.ExecuteNonQuery() > 0)
{
countUpdate++;
}
}
catch
{
errorCount++;
}
}
为什么examTypeWill 始终是第一个?模板列有三个控件...rbtnLiKe,rbtnWenKe,rbtnTeChang