批准asp.net中的错误 [英] approve error in asp.net
本文介绍了批准asp.net中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在管理员登录时批准asp.net中的文档然后他们批准文档2或3天前代码工作正常我再次打开我的项目并批准文档它显示我错误输入字符串是正确的格式
这里是按钮代码。
I >am trying to approve documents in asp.net when admin login then they approve documents 2 or 3 days ago code works fine now when i again open my project and approve documents it shows me error "Input string was in correct format "
here is the button code.
protected void Button1_Click(object sender, EventArgs e)
{
string connStr =
ConfigurationManager.ConnectionStrings["mydms"].ConnectionString;
SqlConnection mySQLconnection = new SqlConnection(connStr);
try{
mySQLconnection.Open();
for (int i = 0; i < Repeater2.Items.Count; i++)
{
DropDownList DropDownListcontrol =
((DropDownList)Repeater2.Items[i].FindControl("DropDownList4"));
Label DocId = ((Label)Repeater2.Items[i].FindControl("DocId"));
SqlCommand cmd = new SqlCommand("approveddd", mySQLconnection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@DocID", SqlDbType.Int).Value =
Convert.ToInt32((DocId.Text));
cmd.Parameters.Add("@ApproveID", SqlDbType.Int).Value =
Convert.ToInt32(DropDownListcontrol.SelectedValue);
cmd.Parameters.Add("@ApproveBy", SqlDbType.VarChar, 50).Value =
(Session["Login2"]);
cmd.ExecuteNonQuery();
DMSLIB.Doc myDoc = new DMSLIB.Doc();
myDoc.MarkDocAs(Convert.ToInt16(DocId.Text),
Convert.ToInt32(DropDownListcontrol.SelectedValue));
}
}
catch (Exception ex)
{
apfi.Text = "Error";
}
finally
{
mySQLconnection.Close();
}
}
请任何人告诉我问题出在哪里发生... ??
推荐答案
输入字符串格式正确错误来自Convert.ToInt32
。
这意味着,您刚刚传递的值无法转换为int。
要查看错误发生的确切位置,请删除try-catch-finally阻止并再次运行。
"Input string was in correct format" error came fromConvert.ToInt32
.
It means, that the value you just passed can not be converted to int.
To see where exactly the error occurs, remove the try-catch-finally block and run again.
这篇关于批准asp.net中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文