关于弹出框 我前台有四个DropDownList,值都为0.1~0.9之间,我后台通过string perc1=DropDownList1.Selectedvalue; 获取前台DropDownList所选中的值,我想设置一个弹出框或什么的,设置一个权限令perc1+perc2+perc3+perc4=1.0如果前台违反这个权限则弹出框提示相加必须为1.0,如果满足条件接着执行数据库更新语句。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你学下JS酒可以搞定了不然什么都要POST回去弄。。 弹出框只能用javascript,后台是弹不出的,具体实现方法有很多种,我在博客里小结了一下:ASP.NET中MessageBox的实现 后台可以的呀,比如if(perc1+perc2+perc3+perc4!=1.0){ Reaponse.Write("<script language=javascript>alert('提示:相加必须为1.0')</script>");}可是这样貌似perc1是string类型的,我得将它强制转换成numeric(我数据库中是次类型)类型的,如何转换? 或者用个try catch语句也可以啊。 这个不还是用javascript么?只不过在服务端调用罢了。而且这种写法不好,应该改成ScriptManager.RegisterStartupScript(this, typeof(Page), Guid.NewGuid().ToString(), "alert('提示:相加必须为1.0');", true);至于类型转换这也太基础了吧 你这个是服务器端执行的代码你总不能DropDownList选择一次就POST回去一次吧? 怎样把DropDownList里获取的值转换成numeric类型啊像这样的int n1=Convert.ToInt32( DropDownList1.SelectedValue); 顺便贴一个sql server和.net数据类型的对照表:SQL Server data type CLR data type (SQL Server) CLR data type (.NET Framework) varbinary SqlBytes, SqlBinary Byte[] binary SqlBytes, SqlBinary Byte[]varbinary(1), binary(1) SqlBytes, SqlBinary byte, Byte[] image None None varchar None None char None Nonenvarchar(1), nchar(1) SqlChars, SqlString Char, String, Char[]nvarchar SqlChars, SqlString String, Char[] nchar SqlChars, SqlString String, Char[] text None None ntext None None uniqueidentifier SqlGuid Guid rowversion None Byte[] bit SqlBoolean Boolean tinyint SqlByte Byte smallint SqlInt16 Int16 int SqlInt32 Int32 bigint SqlInt64 Int64 smallmoney SqlMoney Decimal money SqlMoney Decimal numeric SqlDecimal Decimal decimal SqlDecimal Decimal real SqlSingle Single float SqlDouble Double smalldatetime SqlDateTime DateTime datetime SqlDateTime DateTime sql_variant None ObjectUser-defined type(UDT) None user-defined type table None None cursor None None timestamp None None xml SqlXml None 靠,格式乱了,重贴:SQL Server data type | CLR data type (SQL Server) | CLR data type(Framework)<br />varbinary | SqlBytes, SqlBinary | Byte[] <br />binary | SqlBytes, SqlBinary | Byte[] <br />varbinary(1), binary(1) | SqlBytes, SqlBinary | byte, Byte[] <br />image | None | None <br />varchar | None | None <br />char | None | None <br />nvarchar(1), nchar(1) | SqlChars, SqlString | Char, String, Char[] <br />nvarchar | SqlChars, SqlString | String, Char[] <br />nchar | SqlChars, SqlString | String, Char[] <br />text | None | None <br />ntext | None | None <br />uniqueidentifier | SqlGuid | Guid <br />rowversion | None | Byte[] <br />bit | SqlBoolean | Boolean <br />tinyint | SqlByte | Byte <br />smallint | SqlInt16 | Int16 <br />int | SqlInt32 | Int32 <br />bigint | SqlInt64 | Int64 <br />smallmoney | SqlMoney | Decimal <br />money | SqlMoney | Decimal <br />numeric | SqlDecimal | Decimal <br />decimal | SqlDecimal | Decimal <br />real | SqlSingle | Single <br />float | SqlDouble | Double <br />smalldatetime | SqlDateTime | DateTime <br />datetime | SqlDateTime | DateTime <br />sql_variant | None | Object <br />User-defined type(UDT) | None | user-defined type <br />table | None | None <br />cursor | None | None <br />timestamp | None | None <br />xml | SqlXml | None <br /> decimal d = (decimal)mystring; js中用parseInt将字符串转成数字 C#中用 decimal.Parse(string)或者 Convert.ToDecimal(string) decimal d = (decimal)mystring;无法将string类型转化为decimal 写错了,应该是Convert.ToDecimal(string) 感谢dxd0128和hzzasdf俩位的帮忙,由于我的分数不多,所以只有每人10分,希望不要介意! C# 正则 数字和点 C#动态增减控件的相关问题 新手求助:如何判断选中节点所属的treeview是哪一个? c#键盘钩子的问题,请高手都过来看看 送100分征集建议 .net2005 + SQL2005 集成短信平台 C#中提示"ExecuteNonQuery: CommandText"属性尚未初始化,各位大侠指点一下吧. WinFrom中怎么统计DataGrid中选中的行数 ********接口继承和类继承的问题******** 网页密码安全性如何保证 c#能不能防止其他软件点击关闭按钮? 文件如何绑定另外两个文件~~急啊~ 一句java句转C#
if(perc1+perc2+perc3+perc4!=1.0)
{
Reaponse.Write("<script language=javascript>alert('提示:相加必须为1.0')</script>");
}
可是这样貌似perc1是string类型的,我得将它强制转换成numeric(我数据库中是次类型)类型的,如何转换?
像这样的int n1=Convert.ToInt32( DropDownList1.SelectedValue);
SQL Server data type CLR data type (SQL Server) CLR data type (.NET Framework)
varbinary SqlBytes, SqlBinary Byte[] binary SqlBytes, SqlBinary Byte[]
varbinary(1), binary(1) SqlBytes, SqlBinary byte, Byte[] image None None varchar None None char None None
nvarchar(1), nchar(1) SqlChars, SqlString Char, String, Char[]
nvarchar SqlChars, SqlString String, Char[] nchar SqlChars, SqlString String, Char[] text None None ntext None None uniqueidentifier SqlGuid Guid rowversion None Byte[] bit SqlBoolean Boolean tinyint SqlByte Byte smallint SqlInt16 Int16 int SqlInt32 Int32 bigint SqlInt64 Int64 smallmoney SqlMoney Decimal money SqlMoney Decimal numeric SqlDecimal Decimal decimal SqlDecimal Decimal real SqlSingle Single float SqlDouble Double smalldatetime SqlDateTime DateTime datetime SqlDateTime DateTime sql_variant None Object
User-defined type(UDT) None user-defined type table None None cursor None None timestamp None None xml SqlXml None
SQL Server data type | CLR data type (SQL Server) | CLR data type(Framework)<br />
varbinary | SqlBytes, SqlBinary | Byte[] <br />
binary | SqlBytes, SqlBinary | Byte[] <br />
varbinary(1), binary(1) | SqlBytes, SqlBinary | byte, Byte[] <br />
image | None | None <br />
varchar | None | None <br />
char | None | None <br />
nvarchar(1), nchar(1) | SqlChars, SqlString | Char, String, Char[] <br />
nvarchar | SqlChars, SqlString | String, Char[] <br />
nchar | SqlChars, SqlString | String, Char[] <br />
text | None | None <br />
ntext | None | None <br />
uniqueidentifier | SqlGuid | Guid <br />
rowversion | None | Byte[] <br />
bit | SqlBoolean | Boolean <br />
tinyint | SqlByte | Byte <br />
smallint | SqlInt16 | Int16 <br />
int | SqlInt32 | Int32 <br />
bigint | SqlInt64 | Int64 <br />
smallmoney | SqlMoney | Decimal <br />
money | SqlMoney | Decimal <br />
numeric | SqlDecimal | Decimal <br />
decimal | SqlDecimal | Decimal <br />
real | SqlSingle | Single <br />
float | SqlDouble | Double <br />
smalldatetime | SqlDateTime | DateTime <br />
datetime | SqlDateTime | DateTime <br />
sql_variant | None | Object <br />
User-defined type(UDT) | None | user-defined type <br />
table | None | None <br />
cursor | None | None <br />
timestamp | None | None <br />
xml | SqlXml | None <br />
无法将string类型转化为decimal