问题描述
usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Collections;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Web.UI.HtmlControls;publicpartialclassedit:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){if(!IsPostBack){BindDdlXQ();BindDdlXK();//获取前一个页面传递过来的参数是否为空来判断是修改还是添加if(Request.QueryString["code"]!=null){//获取前一个页面传递过来的参数值BindPageInfo(Request.QueryString["code"].ToString());}}}privatevoidBindPageInfo(stringcode){stringsql=@"select*fromquestionwherequestionid='"+code+"'";DataTabledt=SqlDataBase.ExecuteQuery(sql);if(dt!=null&&dt.Rows.Count>0){txtTitle.Text=dt.Rows[0]["Title"].ToString();txtA.Text=dt.Rows[0]["OptionA"].ToString();txtB.Text=dt.Rows[0]["OptionB"].ToString();txtC.Text=dt.Rows[0]["OptionC"].ToString();txtD.Text=dt.Rows[0]["OptionD"].ToString();txtAnswer.Text=dt.Rows[0]["Answer"].ToString();}}privatevoidBindDdlXQ(){ddlXQ.Items.Clear();stringstrSql=@"selectdistinctSemesterfromCourse";DataTabledt=SqlDataBase.ExecuteQuery(strSql);if(dt!=null){for(inti=0;i<dt.Rows.Count;i++){ListItemitem=newListItem();item.Text=dt.Rows[i]["Semester"].ToString();item.Value=dt.Rows[i]["Semester"].ToString();ddlXQ.Items.Add(item);}ddlXQ.DataBind();}}privatevoidBindDdlXK(){ddlXK.Items.Clear();stringstrXQValue=ddlXQ.SelectedItem.Value;if(strXQValue.Length==0)return;stringstrSql=@"selectdistinctCourseID,CourseNamefromCoursewhereSemester='"+strXQValue+"'";DataTabledt=SqlDataBase.ExecuteQuery(strSql);if(dt!=null){for(inti=0;i<dt.Rows.Count;i++){ListItemitem=newListItem();item.Text=dt.Rows[i]["CourseName"].ToString();item.Value=dt.Rows[i]["CourseID"].ToString();ddlXK.Items.Add(item);}ddlXK.DataBind();}}protectedvoidddlXQ_SelectedIndexChanged(objectsender,EventArgse){BindDdlXK();}protectedvoidButton1_Click(objectsender,EventArgse){stringstrCourseId=ddlXK.SelectedItem.Value;stringstrTitle=txtTitle.Text;stringstrA=txtA.Text;stringstrB=txtB.Text;stringstrC=txtC.Text;stringstrD=txtD.Text;stringstrAnswer=txtAnswer.Text;introw=0;if(Request.QueryString["code"]!=null){stringsql=@"updatequestionsetCourseID='"+strCourseId+"',Title='"+strTitle+"',OptionA='"+strA+"',OptionB='"+strB+"',OptionC='"+strC+"',OptionD='"+strD+"',Answer='"+strAnswer+"'wherequestionid='"+Request.QueryString["code"].ToString()+"'";row=SqlDataBase.ExecuteUpdate(sql);}else{stringsql=@"insertintoquestion(CourseID,Title,OptionA,OptionB,OptionC,OptionD,Answer)values('"+strCourseId+"','"+strTitle+"','"+strA+"','"+strB+"','"+strC+"','"+strD+"','"+strAnswer+"')";row=SqlDataBase.ExecuteUpdate(sql);}if(row>0){Response.Redirect("Default.aspx");}}}
解决方案
解决方案二:
什么代码不懂,还是全都不懂。
解决方案三:
一步一步调试,找到外部接口或者Page页面入口点(具体去参考msdn),然后打断点调试即可!