private void Button2_Click(object sender, System.EventArgs e)
{
for(int j=0;j<CheckBoxList2.Items.Count;j++)
{
if(CheckBoxList2.Items[j].Selected==true)
{
string aaa=CheckBoxList2.Items[j].Value.Trim();
for(int i=0;i<CheckBoxList1.Items.Count;i++)
{
if(CheckBoxList1.Items[i].Selected==true)
{
string cc=CheckBoxList1.Items[i].Value.Trim();
for(int k=0;k<DataGrid1.Items.Count;k++)
{
string studentid=((Label)DataGrid1.Items[k].FindControl("Label3")).Text;
string strSQL="select * from kaoshi_result where grade_name='"+DropDownList2.SelectedItem.Value+"' and class_name='"+aaa+"' and kaoshi_code='"+DropDownList1.SelectedItem.Value+"' and id='"+studentid+"'";
SqlDataAdapter da=new SqlDataAdapter(strSQL,myConnection);
DataSet ds=new DataSet();
da.Fill(ds,"database");
string dd=ds.Tables["database"].Rows[0][""+cc+""].ToString();
string oldzf=ds.Tables["database"].Rows[0]["zhongfen2"].ToString();
float ff=float.Parse(oldzf)+float.Parse(dd);
string updateCmd = "UPDATE kaoshi_result set zhongfen2='"+ff+"' where id='"+studentid+"'";
SqlCommand myCommand2=new SqlCommand(updateCmd,myConnection);
myCommand2.Connection.Open();
myCommand2.ExecuteNonQuery();
myConnection.Close();
myCommand2.Connection.Close();
}
}
}
}
}
Label5.Text="参考科目总分处理完毕";
Button2.Enabled=false;
} private void Button8_Click(object sender, System.EventArgs e)
{
for(int k=0;k<DataGrid1.Items.Count;k++)
{
Button8.Attributes ["onclick"]="javascript:return confirm('是否删除?');";
//string studentid=((Label)DataGrid1.Items[k].FindControl("Label3")).Text;
string strCommand="delete from kaoshi_result where grade_name='"+DropDownList2.SelectedItem.Value+"' and kaoshi_code='"+DropDownList1.SelectedItem.Value+"' and yw='-1' and sx='-1' and wy='-1'";
SqlCommand myCommand=new SqlCommand(strCommand,myConnection);
myCommand.Connection.Open();
myCommand.ExecuteNonQuery();
myCommand.Connection.Close();
}
Response.Write("<script language=Javascript>");
Response.Write("alert('记录删除成功!');");
Response.Write("</script>");
}
{
for(int j=0;j<CheckBoxList2.Items.Count;j++)
{
if(CheckBoxList2.Items[j].Selected==true)
{
string aaa=CheckBoxList2.Items[j].Value.Trim();
for(int i=0;i<CheckBoxList1.Items.Count;i++)
{
if(CheckBoxList1.Items[i].Selected==true)
{
string cc=CheckBoxList1.Items[i].Value.Trim();
for(int k=0;k<DataGrid1.Items.Count;k++)
{
string studentid=((Label)DataGrid1.Items[k].FindControl("Label3")).Text;
string strSQL="select * from kaoshi_result where grade_name='"+DropDownList2.SelectedItem.Value+"' and class_name='"+aaa+"' and kaoshi_code='"+DropDownList1.SelectedItem.Value+"' and id='"+studentid+"'";
SqlDataAdapter da=new SqlDataAdapter(strSQL,myConnection);
DataSet ds=new DataSet();
da.Fill(ds,"database");
string dd=ds.Tables["database"].Rows[0][""+cc+""].ToString();
string oldzf=ds.Tables["database"].Rows[0]["zhongfen2"].ToString();
float ff=float.Parse(oldzf)+float.Parse(dd);
string updateCmd = "UPDATE kaoshi_result set zhongfen2='"+ff+"' where id='"+studentid+"'";
SqlCommand myCommand2=new SqlCommand(updateCmd,myConnection);
myCommand2.Connection.Open();
myCommand2.ExecuteNonQuery();
myConnection.Close();
myCommand2.Connection.Close();
}
}
}
}
}
Label5.Text="参考科目总分处理完毕";
Button2.Enabled=false;
} private void Button8_Click(object sender, System.EventArgs e)
{
for(int k=0;k<DataGrid1.Items.Count;k++)
{
Button8.Attributes ["onclick"]="javascript:return confirm('是否删除?');";
//string studentid=((Label)DataGrid1.Items[k].FindControl("Label3")).Text;
string strCommand="delete from kaoshi_result where grade_name='"+DropDownList2.SelectedItem.Value+"' and kaoshi_code='"+DropDownList1.SelectedItem.Value+"' and yw='-1' and sx='-1' and wy='-1'";
SqlCommand myCommand=new SqlCommand(strCommand,myConnection);
myCommand.Connection.Open();
myCommand.ExecuteNonQuery();
myCommand.Connection.Close();
}
Response.Write("<script language=Javascript>");
Response.Write("alert('记录删除成功!');");
Response.Write("</script>");
}
解决方案 »
- 在XP下TFS连接不了服务器
- 求助,鼠标移上去设置右边层的图片src和超链接的href
- 在ASP.NET中用了HTML表单.该如何得到表单里传的值.
- 创建数据搜索时碰到小问题,请帮忙一下
- 网站上有人可能做了个自动回复的工具,不断的提交自己的回复,请问有没有什么好的办法?除了封IP和帐户以及使用附加码这些办法>
- 我这个存储分页不能按其他字段排序,请教怎么修改后能按其他字段排序?
- textbox 验证问题
- GridView用confirm怎么去获取返回值
- 谁用写过或者用过能在网页上支持flv,mp4,3gp的播放器,最主要的是能支持3gp
- 怎样实现强行下载?
- odbc调用sql存储过程出错
- 一个关于TextBox控件的问题,谢谢!
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.IndexOutOfRangeException: 在位置 0 处没有任何行。源错误:
行 322: DataSet ds=new DataSet();
行 323: da.Fill(ds,"database");
行 324: string dd=ds.Tables["database"].Rows[0][""+cc+""].ToString();
行 325: string oldzf=ds.Tables["database"].Rows[0]["zhongfen"].ToString();
行 326: //string oldzf=((Label)DataGrid1.Items[k].FindControl("Label2")).Text;
源文件: d:\site\manage\sys\chengjichuli.aspx.cs 行: 324
你的sql语句对不对啊,有没有选择出数据出来?
if(ds.Tables["database"].Rows.Count>0)
{
你的操作
}
else
{
表示没有取到数据.
}