在发布信息中提示输入错误的代码。在下面的代码中写代码,写提示输入错误的代码:很急很急!各位高手帮忙指点! protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bindSf();
}
} public void bindSf()
{
string sql = "select distinct sf from tb_City";
DataSet ds = dataOperate.getDataset(sql, "tb_City");
this.ddldSf.DataSource = ds.Tables["tb_City"].DefaultView;
ddldSf.DataTextField = "sf";
ddldSf.DataValueField = "sf";
this.ddldSf.DataBind();
}
//联动终点城市
protected void ddldSf_SelectedIndexChanged(object sender, EventArgs e)
{
string sf = ddldSf.SelectedValue.ToString();
string sql = "select cs from tb_City where sf='" + sf + "'";
DataSet ds = dataOperate.getDataset(sql, "tb_City");
this.ddldCs.DataSource = ds.Tables["tb_City"].DefaultView;
ddldCs.DataTextField = "cs";
ddldCs.DataValueField = "cs";
this.ddldCs.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
string UserName = Session["UserName"].ToString();
string DepotType = ddlDepotType.SelectedValue;
string DepotCity = ddldSf.SelectedValue.ToString() + ddldCs.SelectedValue.ToString();
string DepotSite = this.txtDepotSite.Text;
string DepotAcreage = this.txtDepotAcreage.Text;
string DepotSum = this.txtDepotSum.Text;
string DepotPrice = this.txtDepotPrice.Text;
int Loading;
int Packing;
int Send;
if (ckbLoading.Checked)
{
Loading = 1;
}
else
{
Loading = 0;
}
if (ckbPacking.Checked)
{
Packing = 1;
}
else
{
Packing = 0;
}
if (ckbSend.Checked)
{
sender = 1;
}
else
{
sender = 0;
} string Linkman = this.txtLinkman.Text;
string Phone = this.txtPhone.Text;
string Term = this.txtTerm.Text;
string Content = this.txtContent.Text;
string FBDate = DateTime.Now.ToString();
string UserType = Session["UserType"].ToString();
string sql = "insert into tb_Depot values('" + UserName + "','" + DepotType + "','" + DepotCity + "','" + DepotSite + "','" +
DepotAcreage + "','" + DepotSum + "','" + DepotPrice + "','" + Loading + "','" + Packing + "','" + sender + "','" + Linkman + "','" + Phone + "','" + Term + "','" + Content + "','" + FBDate + "','" + UserType + "','')"; if (dataOperate.execSQL(sql))
{
txtContent.Text = "";
txtDepotAcreage.Text = "";
txtDepotPrice.Text = "";
txtDepotSite.Text = "";
txtDepotSum.Text = "";
txtLinkman.Text = "";
txtPhone.Text = "";
txtTerm.Text = ""; RegisterStartupScript("true", "<script>alert('发布成功!')</script>");
}
else
{ RegisterStartupScript("false", "<script>alert('发布失败!')</script>");
}
}
{
if (!IsPostBack)
{
bindSf();
}
} public void bindSf()
{
string sql = "select distinct sf from tb_City";
DataSet ds = dataOperate.getDataset(sql, "tb_City");
this.ddldSf.DataSource = ds.Tables["tb_City"].DefaultView;
ddldSf.DataTextField = "sf";
ddldSf.DataValueField = "sf";
this.ddldSf.DataBind();
}
//联动终点城市
protected void ddldSf_SelectedIndexChanged(object sender, EventArgs e)
{
string sf = ddldSf.SelectedValue.ToString();
string sql = "select cs from tb_City where sf='" + sf + "'";
DataSet ds = dataOperate.getDataset(sql, "tb_City");
this.ddldCs.DataSource = ds.Tables["tb_City"].DefaultView;
ddldCs.DataTextField = "cs";
ddldCs.DataValueField = "cs";
this.ddldCs.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
string UserName = Session["UserName"].ToString();
string DepotType = ddlDepotType.SelectedValue;
string DepotCity = ddldSf.SelectedValue.ToString() + ddldCs.SelectedValue.ToString();
string DepotSite = this.txtDepotSite.Text;
string DepotAcreage = this.txtDepotAcreage.Text;
string DepotSum = this.txtDepotSum.Text;
string DepotPrice = this.txtDepotPrice.Text;
int Loading;
int Packing;
int Send;
if (ckbLoading.Checked)
{
Loading = 1;
}
else
{
Loading = 0;
}
if (ckbPacking.Checked)
{
Packing = 1;
}
else
{
Packing = 0;
}
if (ckbSend.Checked)
{
sender = 1;
}
else
{
sender = 0;
} string Linkman = this.txtLinkman.Text;
string Phone = this.txtPhone.Text;
string Term = this.txtTerm.Text;
string Content = this.txtContent.Text;
string FBDate = DateTime.Now.ToString();
string UserType = Session["UserType"].ToString();
string sql = "insert into tb_Depot values('" + UserName + "','" + DepotType + "','" + DepotCity + "','" + DepotSite + "','" +
DepotAcreage + "','" + DepotSum + "','" + DepotPrice + "','" + Loading + "','" + Packing + "','" + sender + "','" + Linkman + "','" + Phone + "','" + Term + "','" + Content + "','" + FBDate + "','" + UserType + "','')"; if (dataOperate.execSQL(sql))
{
txtContent.Text = "";
txtDepotAcreage.Text = "";
txtDepotPrice.Text = "";
txtDepotSite.Text = "";
txtDepotSum.Text = "";
txtLinkman.Text = "";
txtPhone.Text = "";
txtTerm.Text = ""; RegisterStartupScript("true", "<script>alert('发布成功!')</script>");
}
else
{ RegisterStartupScript("false", "<script>alert('发布失败!')</script>");
}
}
解决方案 »
- 求提取网页中信息的 方法
- 怎么用sql语句修改数据库表的架构者
- 实际做网站项目时(C#与ASP.NET2.0),GridView控件大都是后台绑定数据还是编程时利用向导自动填加的SqlDataSource1控件呢?
- gridView问题
- 指定某个DIV刷新而其他的内容不刷新,这种效果如何现实?请高手赐教。
- c#.net 使用Jmail.dll的问题
- 求高手帮忙,谢谢谢谢了
- web.config 伪静态 如何实现一个主机多个网站?
- 讨论一下学ASP.NET 有前途吗?
- 在datagrid中怎样把一列为varch2(8)类型的数据显示成yyyy/mm/dd格式的样子,并且当其为00000000时,显示为"-"!
- System.NullReferenceException: 未将对象引用设置到对象的实例
- 脚本知识
或用验证控件验证输入值
try
{
///.....
}
catch(Exception ex)
{
///ex.Message就是错误信息
}
我的意思是,我在点击发布按钮的时候能够判断提示我在txt控件里面输入的值是否正确,判断出出错在哪里?
对了,就是验证啊,比如:txet 控件只能输入文字,但是我却输入中文,在点击发布按钮的时候提示是在哪个text控件上出错!
下午要交毕业设计了,现在还差个问题没得解决,能不能给我在线联系的代码呢?就是QQ那种,发布信息的时候有QQ号码的填写,但是在查看详细信息的时候能够运用QQ在线联系方式!