public void sh_configration_Update(Object sender, DataGridCommandEventArgs e)
{
string city = ((TextBox)e.Item.Cells[1].Controls[1]).Text;
string price = ((TextBox)e.Item.Cells[2].Controls[1]).Text;
string quickprice = ((TextBox)e.Item.Cells[3].Controls[1]).Text;
SqlConnection connUpdate = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
connUpdate.Open();
String sql_edit = "UPDATE sh_configration " +
"SET city = '" + city.Replace("'","''")+ "'," +
"price = '" + price.Replace("'","''")+ "'," +
"quickprice = '" + quickprice.Replace("'","''")+ "'" +
" WHERE id = " + e.Item.Cells[0].Text;SqlCommand sqlCommandUpdate = new SqlCommand(sql_edit,connUpdate);
sqlCommandUpdate.ExecuteNonQuery();
connUpdate.Close();sql = "Select * FROM sh_configration where isvalid=0";
sh_configration.EditItemIndex = -1;
sh_configration.DataSource = CreateDataSource();
sh_configration.DataBind();}
这是一段更新事件,怎么样在这里判断price和quickprice只能为数字,否则弹出类似Javascript的提示框
{
string city = ((TextBox)e.Item.Cells[1].Controls[1]).Text;
string price = ((TextBox)e.Item.Cells[2].Controls[1]).Text;
string quickprice = ((TextBox)e.Item.Cells[3].Controls[1]).Text;
SqlConnection connUpdate = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
connUpdate.Open();
String sql_edit = "UPDATE sh_configration " +
"SET city = '" + city.Replace("'","''")+ "'," +
"price = '" + price.Replace("'","''")+ "'," +
"quickprice = '" + quickprice.Replace("'","''")+ "'" +
" WHERE id = " + e.Item.Cells[0].Text;SqlCommand sqlCommandUpdate = new SqlCommand(sql_edit,connUpdate);
sqlCommandUpdate.ExecuteNonQuery();
connUpdate.Close();sql = "Select * FROM sh_configration where isvalid=0";
sh_configration.EditItemIndex = -1;
sh_configration.DataSource = CreateDataSource();
sh_configration.DataBind();}
这是一段更新事件,怎么样在这里判断price和quickprice只能为数字,否则弹出类似Javascript的提示框
解决方案 »
- 如何将javascript函数中的值传给后台的方法?
- asp.net 从文件夹下载文件,从数据库里面获取的路径怎么用??
- QQ空间打开后显示相册,再点进去是图片列表,再单击是幻灯片播放的路径
- 页面输出字符问题
- !!!!-----------------高分求教---------------------水晶报表如何发布成这个样子?
- 如何改变WebResource.axd的地址,请幕白兄出手相助
- VS2005,部署的程序在WIN2000上可以正常部署浏览,可是在WIN2003上怎么也不行,是什么原因呢?
- 请教一问题.关于DataList
- 如何在asp.net里调用拥有两个个输入参数一个输出参数的存储过程啊?急!!!在线等待
- dropdownlist 实现 中文 和 英文切换网页是如何实现的!在线等!!
- 怎样给ListBox中的项增加双击事件,实现这样的功能?
- ¥#·#¥如果将Session传来的字符串型的数组,转换为整型的数组¥#·#¥¥#·#¥¥#·#¥
response.write("<script>alert('no')</script>")
exit
end if
{
response.write("<script>window.alert('只能为数字!')</script>")
return;
}
{
pricee = int.Parse(price);
quickpricee = int.Parse(quickprice);
}
catch
{
Response.Write("输入只能为数字");
}
response.write("<script>alert('no')</script>")
exit
end if
能告诉我这一句具体应该加在哪里吗??最好是针对我上面的程序来说
string city = ((TextBox)e.Item.Cells[1].Controls[1]).Text;
string price = ((TextBox)e.Item.Cells[2].Controls[1]).Text;
string quickprice = ((TextBox)e.Item.Cells[3].Controls[1]).Text;
你最好在增加的时候也判断一下
function keydownevent(){
if((window.event.keyCode>95 && window.event.keyCode<106) //小键盘的数字键
|| (window.event.keyCode>47 && window.event.keyCode<59 && window.event.keyCode!=16) //大键盘的数字键
|| window.event.keyCode == 8 //退格键
|| window.event.keyCode == 9 //Tab键
|| window.event.keyCode == 13 //回车
|| window.event.keyCode == 46 //Delete功能键
|| window.event.keyCode == 37 //左移键头
|| window.event.keyCode == 39) {
}
else {
window.event.returnValue =0;
return false;
}
}