private void cmdFindSelected_Click(object sender, System.EventArgs e)
  {
   System.Web.UI.WebControls.CheckBox chkExport;
   String sID;
   //循环取的DataGrid控件中选定项的值
   foreach(DataGridItem oDataGridItem in dgCheckBox.Items)
   {
    chkExport = (CheckBox)oDataGridItem.FindControl("chkExport");
    //如果选中了则取值
    
    if(chkExport.Checked)
    {
     Message.Text=((Label)(oDataGridItem.FindControl("lblColumn"))).Text;
     string s=Message.Text;
    SqlConnection conn = new SqlConnection("server=DINGJUNJ-496C51;uid=sa;pwd=;database=student");
   
    SqlDataAdapter  cmdStudent = new SqlDataAdapter("select * from student where name='"+s+"'", conn);
    
DataSet ds=new DataSet();
cmdStudent.Fill(ds,"student");
   
     dgCheckBox.DataSource = ds.Tables["student"];
     dgCheckBox.DataBind();
     }  
   }
}
就是不进行删除操作的时候,可以把我选择的数据显示出来用checkbox
可是添加了删除操作的时候就出现了
 
“/WebStudent”应用程序中的服务器错误。 
第 1 行: '*' 附近有语法错误。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 
异常详细信息: System.Data.SqlClient.SqlException: 第 1 行: '*' 附近有语法错误。
源错误: 
 行 123:						DataSet ds=new DataSet();
行 124:
行 125:					cmdStudent.Fill(ds,"student");
行 126:
行 127:			
源文件: d:\asp.net\webstudent\delete.aspx.cs    行: 125 
堆栈跟踪: 
 [SqlException: 第 1 行: '*' 附近有语法错误。]
   System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
   System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
   System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
   System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
   CommonFunction.DataGridCheckBox.cmdFindSelected_Click(Object sender, EventArgs e) in d:\asp.net\webstudent\delete.aspx.cs:125
   System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   System.Web.UI.Page.ProcessRequestMain()
我把delete改为select可还有错!不知道什么原应!!请教!!!谢谢

 
											





 
	    