无法将类型为“System.Byte[*]”的对象强制转换为类型“System.Byte[]”。 [问题点数:40分,结帖人testcs_dn]

Bbs1
本版专家分:28
Blank
GitHub 绑定GitHub第三方账户获取
结帖率 83.33%
Bbs3
本版专家分:791
Bbs3
本版专家分:791
Bbs1
本版专家分:28
Blank
GitHub 绑定GitHub第三方账户获取
Bbs1
本版专家分:28
Blank
GitHub 绑定GitHub第三方账户获取
无法类型为“System.String”的对象强制转换类型“System.Byte[]”
MemoryStream MStream = new MemoryStream((byte[])myds.Tables[0].Rows[0][1]);rnrn数据库中存的 是System.Byte[]<em>类型</em>的啊。该怎么处理呢?
无法类型为“System.DBNull”的对象强制转换类型“System.Byte[]”
这是说明<em>对象</em>为空了,就不能强转了,返回值是null,所以不能进行转换操作 比如 byte[])reader["zp"]为空 只要加层判断即可 C#代码  if (reader["zp"] != DBNull.Value)  {      MemoryStream ms = new MemoryStream((byte[])reader["zp"]);
急!!无法类型为“System.Byte[]”的对象强制转换类型“System.IConvertible”。
我用UTF8的格式将字符串转化成Byte[]的格式存入到SQL数据库varbinary<em>类型</em>,为什么我从数据库取出来的时候就会报 <em>无法</em>将<em>类型</em>为“System.Byte[]”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.IConvertible”。请高人指教。在线等rnrn
错误:无法类型为“System.DBNull”的对象强制转换类型“System.Byte[]”。
我在读取员工图片时遇到这个错误!如何解决?这是说明<em>对象</em>为空了,就不能强转了,返回值是null,所以不能进行转换操作 比如 byte[])reader["zp"]为空 只要加层判断即可                if (dr.GetValue(7) != DBNull.Value)                {                    imagebytes = (b
无法将类型为“System.String”的对象强制转换类型“System.Byte[]”。"">请高手解答 "无法类型为“System.String”的对象强制转换类型“System.Byte[]”。"
DataSearch l_DataSearch = new DataSearch();rnrnrnrn //ldt_data = l_DataSearch.Search_FillImage(s_yy.Text, e_yy.Text);rn ldt_data.Columns.Add("年");rn ldt_data.Columns.Add("月");rn ldt_data.Columns.Add("日");rn ldt_data.Columns.Add("时");rn ldt_data.Columns.Add("气压层次");rn ldt_data.Columns.Add("气象台名称");rn ldt_data.Columns.Add("气象预报区域");rn ldt_data.Columns.Add("填图<em>类型</em>");rn ldt_data.Columns.Add("填图员");rn ldt_data.Columns.Add("分析员");rn ldt_data.Columns.Add("Fimage");rnfor (int i = 1; i < 17; i++)rn rn DataRow l_datarow = ldt_data.NewRow();rn l_datarow[0] = "2007";rn l_datarow[1] = "12";rn l_datarow[2] = i.ToString();rn l_datarow[3] = "12";rn l_datarow[4] = "5";rn l_datarow[5] = "a" + i.ToString();rn l_datarow[6] = "b" + i.ToString();rn l_datarow[7] = "c" + i.ToString();rn l_datarow[8] = "张三";rn l_datarow[9] = "李四";rnrn FileStream fs = new FileStream("E:\\pic_test\\"+i.ToString()+".JPG", FileMode.Open, FileAccess.Read);rn BinaryReader br = new BinaryReader(fs);rn byte[] photo = br.ReadBytes((int)fs.Length);rnrnrn br.Close();rn fs.Close();rn l_datarow[10] = photo;rn ldt_data.Rows.Add(l_datarow);rn rnResponse.BinaryWrite((byte[])ldt_pic.Rows[1][10]);
无法类型为“Chem.Model.WebClassInfo”的对象强制转换类型“System.Data.DataRowView”
[code=C#]rn Repeater rdr = e.Item.FindControl("NavItem") as Repeater;rn DataRowView row = (DataRowView)e.Item.DataItem;rn string WebClassID = ReturnValue.GetObjString(row["WebClassID"]);rn rdr.DataSource = BWebClass.GetWebClassReader(WebClassID);rn rdr.DataBind();rn[/code]rnDataRowView row = (DataRowView)e.Item.DataItem;rn实体<em>对象</em>不能转换为DataRowView吗?rn必须改用DataTable吗?
无法类型为“FluorineFx.ASObject”的对象强制转换类型
columns是ArrayCollection <em>类型</em>的rnflex传了一个ArrayCollection <em>类型</em>的参数columns,在.net后台使用此参数时报错误:rnforeach (DataGridDetailsVO item in columns)//出错代码rnrn<em>无法</em>将<em>类型</em>为“FluorineFx.ASObject”的<em>对象</em><em>强制转换</em>为<em>类型</em>“ServiceLibrary.VO.DataGridDetailsVO”。rnrn其中DataGridDetailsVO为VO实体类。rn奇怪的是程序第一次打开网页运行时不报错,关了网页再打开这页面才报上面的错误,什么原因啊?谢谢!我强制转化了一下也不行rn
无法类型为“ASP.Letters_treat_ascx”的对象强制转换类型“XX.Controls.Treat”。
<em>无法</em>将<em>类型</em>为“ASP.Letters_treat_ascx”的<em>对象</em><em>强制转换</em>为<em>类型</em>“XX.Controls.Treat”。rn[code=C#]rnrn[/code]rn请高手指点如何解决
无法类型为“MYL.SQL.MyHander”的对象强制转换类型“System.Web.UI.Page”。
我写了一个 MyHander累.为的是防止SQL注入,实现了IHttpHandler, IRequiresSessionState 这两个接口,其他页面都没问题,在编辑器中上传图片的时候会报错,提示如下:rnrn“/”应用程序中的服务器错误。rn--------------------------------------------------------------------------------rnrn<em>无法</em>将<em>类型</em>为“MYL.SQL.MyHander”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Web.UI.Page”。 rn说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 rnrn异常详细信息: System.InvalidCastException: <em>无法</em>将<em>类型</em>为“MYL.SQL.MyHander”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Web.UI.Page”。rnrn源错误: rnrnrn行 137:rn行 138: type = ResourceType.Add( "Files" );rn行 139: type.Url = BaseUrl + "files/";rn行 140: type.Dir = BaseDir == "" ? "" : BaseDir + "files/";rn行 141: type.MaxSize = 0;rnrn使用的编辑器为:ckfinderrn望大侠们帮下忙rnrnwebcongif中:rn rn rn rn
无法类型为“System.Web.UI.HtmlControls.HtmlForm”的对象强制转换类型“System.Web.UI.WebControls.
Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs)rn rn Dim TA As New BTACScotTableAdapters.OrderHandlingTableAdapterrn Dim uid As String = Page.User.Identity.Name.ToString()rn Dim rows As GridViewRow = CType(CType(e.CommandSource, Control).Parent.Parent, GridViewRow)rnrn Dim field01 As String = CType(rows.FindControl("Textbox1"), TextBox).Textrn Dim field02 As String = CType(rows.FindControl("Textbox2"), TextBox).Textrn Select Case e.CommandName.ToUpperrn Case "APPROVE"rn错误行:rn Dim rows As GridViewRow = CType(CType(e.CommandSource, Control).Parent.Parent, GridViewRow)rn错误信息:rnrn <em>无法</em>将<em>类型</em>为“System.Web.UI.HtmlControls.HtmlForm”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Web.UI.WebControls.GridViewRow”。rnrn 分页用的是gridview自带的分页 页面第一次打开时效果正常,点击分页就异常了 希望高手只招谢谢,rnrnrnrn
无法类型为“OPCAutomation.OPCServerClass”的对象强制转换类型“OPCAutomation.IOPCGroups”。
http://bbs.gongkong.com/d/201604/669742_1.shtmlhttps://blog.csdn.net/wfx7414/article/details/49619419https://bbs.csdn.net/topics/391919784#https://bbs.csdn.net/topics/390775150https://bbs.csdn.net/top...
无法类型为“System.Data.DataRowView”的对象强制转换类型“System.IConvertible”。
原因和解决办法:https://www.cnblogs.com/liuhonghai/archive/2010/03/31/1701211.html
无法类型为System.DBNull的对象强制转换类型System.Int32
<em>无法</em>将<em>类型</em>为System.DBNull的<em>对象</em><em>强制转换</em>为<em>类型</em>System.Int32rn这是什么原因哪 rn大虾们给个理由rn不是string 反而是 int32 ,为什么我测程序总是有各种莫名其妙的错误。rn
无法类型为“ASP.abc_ascx”的对象强制转换类型“abc”。
动态加载用户控件: rnabc buc = (abc)LoadControl("abc.ascx");rn buc.name= "123";rn Controls.Add(buc);rnrn报错:rn<em>无法</em>将<em>类型</em>为“ASP.abc_ascx”的<em>对象</em><em>强制转换</em>为<em>类型</em>“abc”。
无法类型为“System.Xml.XmlComment”的对象强制转换类型“System.Xml.XmlElement”。
if (result == "del")rn rn string id = Convert.ToString(Request.QueryString["id"]);rn XmlDocument xmlDoc = new XmlDocument();rn xmlDoc.Load(Server.MapPath("../Ch/swf/pic.xml"));rn XmlNode root = xmlDoc.SelectSingleNode("folio");rn XmlNodeList xnl = xmlDoc.SelectSingleNode("folio").ChildNodes;rn for (int j = 0; j < xnl.Count; j++)rn rn XmlNode xn = xnl.Item(j);rn [color=#FF0000] XmlElement xe = (XmlElement)xnl.Item(j);[/color] //这个报错 rn if(xe["ID"].InnerText == id.ToString())rn rn root.RemoveChild(xe);rn break;rnrn rn rn xmlDoc.Save(Server.MapPath("../Ch/swf/pic.xml"));rn rnrnrnrn求高手解决
无法类型为“System.DBNull”的对象强制转换类型“System.String”。
[code=C#]SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.AppConnectionString, CommandType.Text, sql, para);rn while (reader.Read()) rn rn Hotelbook hotelbook = new Hotelbook();rn hotelbook.Name = (string)reader["Name"];rn hotelbook.StayTime = (string)reader["StayTime"];rn hotelbook.LeaveTime = (string)reader["LeaveTime"];rn hotelbook.RoomNumber = (int)reader["RoomNumber"];rn hotelbook.PeopleNumber = (int)reader["PeopleNumber"];rn hotelbook.Phone = (string)reader["Phone"];rn hotelbook.Id = (int)reader["Id"];rn hotelbook.SFZNumber = (string)reader["SFZNumber"];rn hotelbook.RoomTypeId = (string)reader["RoomTypeId"];rn [color=#FF0000]hotelbook.IsAudit = (string)reader["IsAudit"][/color] hotelbooks.Add(hotelbook);rn [/code]rnrnrn我知道是数据库里面有空值 怎么改呢
无法类型为“ArrayList”的对象强制转换类型“System.String[,]”
<em>无法</em>将<em>类型</em>为“ArrayList”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.String[,]”,ArrayList是二维数组rnrnpublic void WriteText(StreamWriter streamWriter, ref ArrayList dim2valueList)rnrn for (int i = 0; i < dim2valueList.Count;i++ )rn rn string[,] dim2Value = (string[,])dim2valueList[i];//报错,
无法类型为“System.Security.Principal.GenericPrincipal”的对象强制转换类型“NewPrincipal”
<em>无法</em>将<em>类型</em>为“System.Security.Principal.GenericPrincipal”的<em>对象</em><em>强制转换</em>为<em>类型</em>“NewPrincipal”,1.1下不报错,2.0就报这个错,这个问题该怎么解决使得两种情况能够兼容?
无法类型为“ASP.masterpage_master”的对象强制转换类型“ASP.masterpage_master”。
为什么 页面运行的时候rnrn经常出现这种没有理由的错误??rn高手给点建议rnrn到底是哪里错了
无法类型为“System.Data.DataView”的对象强制转换类型“System.Data.SqlClient.SqlDataReader”。
[code=csharp]rn[img=https://img-bbs.csdn.net/upload/201801/06/1515246989_308095.png][/img]rnrn[/code]
无法类型为“System.Web.UI.LiteralControl”的对象强制转换类型“System.Web.UI.WebControls.TextBox
<em>无法</em>将<em>类型</em>为“System.Web.UI.LiteralControl”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Web.UI.WebControls.TextBox”rn我知道<em>类型</em>不对 但不知道怎么改 rn string b = "update Record set CreatTime='" + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[0].Controls[0])).Text.ToString().Trim()+"' where WorkID='" +GridView1.DataKeys[e.RowIndex].Value.ToString() + "'"; rnrnrnCreatTime是时间<em>类型</em>
无法类型为“System.Web.UI.WebControls.TextBox”的对象强制转换类型“System.IConvertible”
Default.aspx代码: rnrn rnrn rnrn rn rn 无标题页 rn rn rn rn rn rn rn rn rn rn rn rn rn rnrnrnDefault.aspx.cs代码: rnrnrnusing System; rnusing System.Configuration; rnusing System.Data; rnusing System.Linq; rnusing System.Web; rnusing System.Web.Security; rnusing System.Web.UI; rnusing System.Web.UI.HtmlControls; rnusing System.Web.UI.WebControls; rnusing System.Web.UI.WebControls.WebParts; rnusing System.Xml.Linq; rnrnusing System.Data.SqlClient; rnrnrnpublic partial class _Default : System.Web.UI.Page rn rn protected void Page_Load(object sender, EventArgs e) rn rnrn rn protected void Button1_Click(object sender, EventArgs e) rn rn SqlConnection Con = new SqlConnection("Data Source=Localhost; Initial Catalog=EX_NEW; User ID=sa;Pwd=photosystem;"); rn String SqlCmd = "SELECT * FROM ImageStore WHERE ImageID = @ImageID"; rn SqlCommand CmdObj = new SqlCommand(SqlCmd, Con); rn CmdObj.Parameters.Add("@ImageID", SqlDbType.Int).Value = Convert.ToInt32(Ima); rn Con.Open(); rn SqlDataReader SqlReader = CmdObj.ExecuteReader(); rn SqlReader.Read(); rn Response.ContentType = (string)SqlReader["ImageContentType"];//设定输出文件<em>类型</em> rn //输出图象文件二进制数制 rn Response.OutputStream.Write((byte[])SqlReader["ImageData"], 0, (int)SqlReader["ImageSize"]); rn Response.End(); rn Con.Close(); rn rn rnrnrn"CmdObj.Parameters.Add("@ImageID", SqlDbType.Int).Value = Convert.ToInt32(Ima);" rnrn报错:"<em>无法</em>将<em>类型</em>为“System.Web.UI.WebControls.TextBox”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.IConvertible”。" rn
无法类型为“System.Web.UI.LiteralControl”的对象强制转换类型“System.Web.UI.WebControls.TextBox”
请问在vs2005中编写ASP.NET程序,以下语句rnstring s5 = ((TextBox)e.Item.Cells[2].Controls[0]).Text;rn执行时会提示<em>无法</em>将<em>类型</em>为“System.Web.UI.LiteralControl”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Web.UI.WebControls.TextBox” rn该如何解决?
无法类型为“System.Web.UI.LiteralControl”的对象强制转换类型“System.Web.UI.WebControls.LinkButton”。
一个删除记录的操作,代码如下:rn Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)rn rn If e.Row.RowState = DataControlRowState.Normal Or e.Row.RowState = DataControlRowState.Alternate Thenrn rn If e.Row.Cells(5).Controls.Count <> 0 Thenrn rn [color=#FF0000] Dim btndelete As LinkButton = CType(e.Row.Cells(5).Controls(0), LinkButton)[/color]rn rn If btndelete IsNot Nothing Thenrn rn btndelete.Attributes("onclick") = "return confirm('您确定要删除该记录吗?')"rn rn End Ifrn rn End Ifrn rn End Ifrn rn End Sub
无法类型为“System.Data.DataRow”的对象强制转换类型“System.Data.DataRowView”。
aspx页面.rnrn rn rn rn rn rn rn rn rnrn rn rn rn rn rnrnCS:rn DataSet ds = new DataSet();rn string Sconnection = @"server=.;database=bbs;uid=sa;pwd=wwwtqbbacom";rn using (SqlConnection conn = new SqlConnection(Sconnection))rn rnrn SqlDataAdapter sd = new SqlDataAdapter("select*from tbClass;select*from tbBoard",conn);rn sd.Fill(ds);rn rn ds.Relations.Add("relat",ds.Tables[0].Columns["ClassId"],ds.Tables[1].Columns["BoardClassID"]);rn Repeater1.DataSource =ds;rn Repeater1.DataBind();rn为什么会出现这个错误:<em>无法</em>将<em>类型</em>为“System.Data.DataRow”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Data.DataRowView”。
无法类型为“Finisar.SQLite.SQLiteConnection”的对象强制转换类型“System.Data.Common.DbConnection”。
将 NHibernate.Driver.SQLiteDriver 改为 NHibernate.Driver.SQLite20Driver
无法类型为“sysdata.sysdataDataSet的对象强制转换类型”system.componentModel.Componet
<em>无法</em>将<em>类型</em>为“sysdata.sysdataDataSet的<em>对象</em><em>强制转换</em>为<em>类型</em>”system.componentModel.Componetrnrn这句是什么意思,提示很多次了,也没有出错行,不知错在什么地方
无法类型为“CrystalDecisions.Shared.ParameterFields”的对象强制转换类型“CrystalDecisions.Share
[img=https://img-bbs.csdn.net/upload/201610/17/1476687338_200638.jpg][/img]rnrnrnrnrnrn ERP报表扩展 rn rnrnrn rn rn rn rn rn rn rnrnrn[code=csharp]using System;rnusing System.Data;rnusing System.Data.OracleClient;rnusing System.Configuration;rnusing System.Collections;rnusing System.Web;rnusing System.Web.Security;rnusing System.Web.UI;rnusing System.Web.UI.WebControls;rnusing System.Web.UI.WebControls.WebParts;rnusing System.Web.UI.HtmlControls;rnusing CrystalDecisions.CrystalReports.Engine;rnusing CrystalDecisions.Shared;rnrnrnnamespace ErpPrintServicernrn public partial class ErpExtReport : System.Web.UI.Pagern rn string rptParth = "", resultKey = "", parameters="";rn protected void Page_Load(object sender, EventArgs e)rn rn loadRptInfo();rn rnrn private void loadRptInfo()rn rn resultKey = Request.QueryString["ResultKey"]; rn if (resultKey != null)rn rn string strSQL = @"SELECT PARAMETERS,FILE_NAME FROM DJ_QUICK_REPORT_ANALYSE_JOIN WHERE QUERY_NO=:ResultKey";rn OracleDataReader odr = OracleHelper.ExecuteReader(CommandType.Text, strSQL, new OracleParameter(":ResultKey", resultKey));rn if (odr.Read())rn rn parameters = odr["parameters"].ToString();rn rptParth = odr["file_name"].ToString();rn rn odr.Close();rn loadPullRpt(rptParth, parameters);rn rn rnrn private void loadPullRpt(string rptParth, string parameters)rn rn // crs.ReportDocument.Load(Server.MapPath(rptParth));rn crs.ReportDocument.Load(@"\\192.168.0.62\CrystalRpt\材料发料.rpt");//绝对路径 rn Utility.SystemSet.SetDBLogonForReport(crs.ReportDocument); rn crv.ReportSource = crs;rn this.crv.ParameterFieldInfo = GetParameterField(parameters);rn crv.DataBind(); rn rn //参数rn private ParameterFields GetParameterField(string parameters)rn rn ParameterFields pfs = new ParameterFields();rnrn string parameter = parameters;rn string paraNameAndValue = "", paraName = "", paraValue = "";rn while (parameter.IndexOf("^") > 0)rn rn paraNameAndValue = parameter.Substring(0, parameter.IndexOf("^"));rnrn paraName = paraNameAndValue.Substring(0, paraNameAndValue.IndexOf("="));rn paraValue = paraNameAndValue.Substring(paraNameAndValue.IndexOf("=") + 1);rn parameter = parameter.Substring(parameter.IndexOf("^") + 1);rnrn pfs.Add(this.CreateParameterField(paraName, paraValue));rn rnrn return pfs;rn rnrn private ParameterField CreateParameterField(string FieldName, object FieldValue)rn rn ParameterField field = new ParameterField();rn ParameterDiscreteValue pvalue = new ParameterDiscreteValue();rnrn pvalue.Value = FieldValue;rn field.Name = FieldName;rn field.CurrentValues.Add(pvalue);rn //返回参数字段rn return field;rn rn rnrn[/code]rn报错如图
无法类型为“System.Web.UI.DataBoundLiteralControl”的对象强制转换类型“System.Web.UI.WebControl
<em>无法</em>将<em>类型</em>为“System.Web.UI.DataBoundLiteralControl”的<em>对象</em><em>强制转换</em>为类“System.Web.UI.WebControls.LinkButton"
无法类型为“System.DBNull”的对象强制转换类型“System.String
//根据sql查询角色权限信息rn private static IList GetSysFunBySql(string safeSql)rn rn List list = new List();rn rn using (DataTable table = DBHelper.GetDataSet(safeSql))rn rn foreach (DataRow row in table.Rows)rn rn SysFun sysFun = new SysFun();rn sysFun.NodeId = (int)row["NodeId"];rn sysFun.DisplayName = (string)row["DisplayName"];rn sysFun.NodeURL = (string)row["NodeURL"];//出问题的语句rn sysFun.DisplayOrder = (int)row["DisplayOrder"];rn sysFun.ParentNodeId = (int)row["ParentNodeId"];rn rn list.Add(sysFun);rn rn rn return list;rn rn rn我的页面有一个是连接,,当一点击连接的时候就提示:<em>无法</em>将<em>类型</em>为“System.DBNull”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Stringrn我数据库表中NodeURL 是空的rn请问一下解决办法是什么..谢谢各位rnrnrnrn
无法类型为“System.Windows.Forms.DataGridViewTextBoxCell”的对象强制转换类型“System.Windows.Fo
<em>无法</em>将<em>类型</em>为“System.Windows.Forms.DataGridViewTextBoxCell”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Windows.Forms.IDataGridViewEditingCell”。rnrnrnrn请教下大家有没有碰到过这个错误?rn没有代码报错,直接跳到Application.Run(new Main());报错。rn也不知道是什么原因造成的。rnrn
无法类型为“System.String”的对象强制转换类型“System.Collections.ArrayList”。
[code=csharp]rn StringBuilder sbList = new StringBuilder();rn for (int i = 0; i < this.Count; i++)rn rn object[] var = this.GetKey(i), this.Get(i) ;rn if (i == 0) sbList.AppendFormat("0=1", var);rn else sbList.AppendFormat("&0=1", var);rn rn[/code]rnrn“/”应用程序中的服务器错误。rn<em>无法</em>将<em>类型</em>为“System.String”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Collections.ArrayList”。rn说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。rnrn异常详细信息: System.InvalidCastException: <em>无法</em>将<em>类型</em>为“System.String”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Collections.ArrayList”。rnrn源错误:rnrnrn行 43: for (int i = 0; i < this.Count; i++)rn行 44: rn行 45: object[] var = this.GetKey(i), this.Get(i) ;rn行 46: if (i == 0) sbList.AppendFormat("0=1", var);rn行 47: else sbList.AppendFormat("&0=1", var);
无法类型为“DataBoundLiteralControl”的对象强制转换类型“WebControls.DropDownList”
一个Datagridrnrn前台代码:rnrn[code=html]rnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrn[/code]rnrn后台代码:rnrn[code=csharp]rnrnpublic void edit(object sender, DataGridCommandEventArgs e)rn rnrnDropDownList list1 = (DropDownList)dgVidicon.Items[e.Item.ItemIndex].Cells[2].Controls[0];rnrn rnrnrn[/code]rnrn程序运行之后报错,出错在这条代码上:rn[color=#008080]rnDropDownList list1 = (DropDownList)dgVidicon.Items[e.Item.ItemIndex].Cells[2].Controls[0];rnrnrn[/color]rnrn出错信息是:rn[color=#008080]rnrn<em>无法</em>将<em>类型</em>为“System.Web.UI.DataBoundLiteralControl”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Web.UI.WebControls.DropDownList”。rnrnrn[/color]
无法类型为“System.EventArgs”的对象强制转换类型“System.Windows.Forms.DataGridViewCellEventArg
从网上下载的教程代码,不应该不行呀,可现实就是不行。rn代码很简单:在窗体上建一个datagridveiw,想达到一个效果,当鼠标浮在某一个单元格上时会弹出一个对话框来。rn[code=vb] Private Sub DataGridView1_MouseHover(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.MouseHoverrn MsgBox(e.RowIndex)rn End Sub[/code]rnrn运行后提示错误:<em>无法</em>将<em>类型</em>为“System.EventArgs”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Windows.Forms.DataGridViewCellEventArgs”rnrn请高手解疑(代码应该没问题,毕竟是抄来的,我怀疑是哪地方设置错了?)rn[img=https://img-bbs.csdn.net/upload/201705/20/1495210268_744740.png][/img]
无法类型为“System.DBNull”的对象强制转换类型“System.String”
“/”应用程序中的服务器错误。rn--------------------------------------------------------------------------------rnrn<em>无法</em>将<em>类型</em>为“System.DBNull”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.String”。 rn说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 rnrn异常详细信息: System.InvalidCastException: <em>无法</em>将<em>类型</em>为“System.DBNull”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.String”。rnrn源错误: rnrnrn行 1829: get rn行 1830: try rn行 1831: return ((string)(this[this.tableProducts.CategoryNameColumn]));rn行 1832: rn行 1833: catch (System.InvalidCastException e) rn rnrn源文件: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\c010e098\1279d163\App_Code.vor1-m9c.5.cs 行: 1831 rnrn堆栈跟踪: rnrn这个怎么解决!!??
无法类型为“System.String”的对象强制转换类型“Newtonsoft.Json.Linq.JObject”
C#, NewtonSoft.json , 转换一个网络服务器返回的字符串,报错:<em>无法</em>将<em>类型</em>为“System.String”的<em>对象</em><em>强制转换</em>为<em>类型</em>“Newtonsoft.Json.Linq.JObject”。字符串内容:&quot;{\&quot;message\&quot;:\&quot;上传成功\&quot;,\&quot;code\&quot;:\&quot;1\&quot;}&quot;代码:JObject objResp = (JObject)JsonConvert.Deserializ...
无法类型为“DAL.LoginDAO”的对象强制转换类型“IDAL.LoginIDAL
敲七层登陆的时候遇到这个问题,报错代码如下return (IDAL.LoginIDAL)Assembly.Load(strDB).CreateInstance("DAL.LoginDAO");//这里需要把类<em>类型</em>转换为接口<em>类型</em>百度的结果是类需要把接口实现才能实现<em>强制转换</em>,回头检查发现没有任何问题,这个类已经实现这个接口了。整个都检查下来都没有发现问题,代码都没错,但是就是会报错,到底是哪的问题呢?经
对象强制转换类型******">ArcEngine 无法类型为"Systerm._ComObject"的对象强制转换类型******
问题如图所示: 解决方法:http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/#/Interacting_with_singleton_objects/00010000043p000000/
无法类型为“OPCAutomation.OPCServerClass”的对象强制转换类型“OPCAutomation.IOPCGroups”。...
2019独角兽企业重金招聘Python工程师标准&gt;&gt;&gt; ...
无法类型为“Microsoft.JScript.GlobalScope”的对象强制转换类型“Microsoft.JScript.StackFrame
<em>无法</em>将<em>类型</em>为“Microsoft.JScript.GlobalScope”的<em>对象</em><em>强制转换</em>为<em>类型</em>“Microsoft.JScript.StackFrame出现这个错误,是因为 Microsoft.JScript 就是个没有完全按照 ECMA 标准写的js引擎,功能非常非常有限。对于回调比较多的代码运行就会出错,错误提示还不够明白。ScriptEngine.cs 调用示例===============...
无法类型为“System.Xml.XmlComment”的对象强制转换类型“System.Xml.XmlElement”...
今天开发C#项目时,有一个需要读取XML的功能点。编码过程中遇到了如标题所示的异常,如下图所示: 查询官网后得知XmlComment是注释节点的<em>类型</em>,如下图所示: 于是得出结论,使用XmlDocument去解析XML文件时,注释也会作为一个节点被加载到节点列表里。因此后续如果需要添加注释的话,可以考虑在节点里增加一个属性“comment”或者“text”专门用来存放注释信息,这样可以大...
无法类型为“System.Web.UI.WebControls.Button”的对象强制转换类型“System.Web.UI.WebControls.TextBox”
<em>无法</em>将<em>类型</em>为“System.Web.UI.WebControls.Button”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Web.UI.WebControls.TextBox”
无法类型为“System.Object[]”的对象强制转换类型“System.Web.UI.WebControls.Xml”。
代码如下所示:rn[code=C#]rn protected void btn_getStuMs_Click(object sender, EventArgs e)rn rn Object[] ms = student.exec("张三", "18", "北大", "男");rn Xml xml;rnrn for (int i = 0; i < ms.Length; i++)rn xml = (Xml)ms[i];rn rn[/code]rn这行 xml = (Xml)ms[i];在<em>类型</em>转换时出错:<em>无法</em>将<em>类型</em>为“System.Object[]”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Web.UI.WebControls.Xml”。rnrn跟踪ms变量结构:rn-msobject[1]rn -[0]object[1]rn -[0]System.Xml.XmlNode[6]rn +[0]Attribute,Name="xsi:type",value="soa:Object"rn +[1]Element,Name="soa:name"rn +[1]Element,Name="soa:age"rn +[1]Element,Name="soa:school"rn +[1]Element,Name="soa:sex"rn +[1]Element,Name="soa:count"rnrn请各位帮忙看看,谢谢!rnrnrnrn
无法类型为“System.Drawing.Bitmap”的对象强制转换类型“System.ComponentModel.IContainer”。
Private _docement As DocementBasern '打印rn Private Sub button3_Click(sender As Object, e As EventArgs) Handles button3.Clickrn If pictureBox1.Image Is Nothing Thenrn MessageBox.Show("You Must Load an Image first!")rn Returnrn Elsern _docement = New imageDocument(pictureBox1.Image)rn End Ifrn _docement.showPrintPreviewDialog()rn End Subrnrnrn_docement = New imageDocument(pictureBox1.Image)这行报错, '<em>无法</em>将<em>类型</em>为“System.Drawing.Bitmap”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.ComponentModel.IContainer”。rnrn其中imageDocument在组件类中有定义rnPublic Class imageDocument : Inherits DocementBasernrn Private _Image As Imagernrn Public Property Image() As Imagernrn Getrn Return _Imagern End Getrnrn Set(value As Image)rn _Image = valuern If _Image IsNot Nothing Thenrn If _Image.Size.Width > _Image.Size.Height Thenrnrn DefaultPageSettings.Landscape = Truern Elsern DefaultPageSettings.Landscape = Falsern End Ifrn End Ifrn End Setrn End Propertyrnrn Public Sub imageDocument()rn End Subrnrn[color=#FF0000] Public Sub imageDocument(image As Image)rn Me.Image = imagern End Sub[/color]
无法类型为“System.String”的对象强制转换类型“LoginEntity”。
登录按钮:rn protected void btnLogin_Click(object sender, EventArgs e)rn rn LoginEntity le = new LoginEntity();rn le.UserName = this.txtUserName.Text;rn le.UserIdentity = this.DropDownList1.SelectedItem.ToString();rn Session.Add("User",le);rn Application.Add("AUser",le);rn Response.Redirect("DisplayLogin.aspx");rn rn rnDisplayLogin.aspx页:rnprotected void Page_Load(object sender, EventArgs e)rn rn LoginEntity le = (LoginEntity)Session["User"];rn Response.Write("用户名是:"+le.UserName+" ");rn Response.Write("身份是:" + le.UserIdentity + " ");rn Response.Write(Application.Count.ToString());rn for (int i = 0; i < Application.Count; i++)rn rn LoginEntity le1 = (LoginEntity)Application["AUser"];rn //LoginEntity le1 = (LoginEntity)Application["AUser"];rn Response.Write("在线用户:+ " + le1.UserName + " 身份是:" + le1.UserIdentity + " ");rn rn rnrnrnrn提示此句:LoginEntity le1 = (LoginEntity)Application["AUser"];rn这个错误:<em>无法</em>将<em>类型</em>为“System.String”的<em>对象</em><em>强制转换</em>为<em>类型</em>“LoginEntity”。
无法类型为“System.Windows.Forms.DataGridViewTextBoxCell”的对象强制转换类型“DevComponents.Dot
<em>无法</em>将<em>类型</em>为“System.Windows.Forms.DataGridViewTextBoxCell”的<em>对象</em><em>强制转换</em>为<em>类型</em>“DevComponents.DotNetBar.Controls.DataGridViewIntegerInputCell”rnrnrn错误如上rn小弟在dataGridViewX中设置了一列DataGridViewIntegerInputColumn列,不知道如何获取他的值,就采取了如下的转换rnConvert.ToInt32(((DataGridViewIntegerInputCell)datagridview.Rows[i].Cells[2]).Value) 就出现了上述错误rn还请各位大虾帮忙!
无法类型为“Plugs.MyConsole”的对象强制转换类型“Plugs.IPlugin”。
http://hi.baidu.com/firstnet/blog/item/9cf48000387ddf8be850cd0c.htmlrn我试了下这个,却提示这个错误。rn<em>无法</em>将<em>类型</em>为“Plugs.MyConsole”的<em>对象</em><em>强制转换</em>为<em>类型</em>“Plugs.IPlugin”。rn谁能帮忙给看下。rn[code=C#]//调用插件内的方法rn private void button2_Click(object sender, EventArgs e)rn rn //获取列表框内被选择的项rn string itemStr = ListItems.SelectedItem.ToString();rn if (ListItems.SelectedIndex >= 0)rn rn if (itemStr == "MyConsole")rn //调用存储在动态数组plugins里面的插件<em>对象</em>的OnShowInfo方法rn [color=#FF0000] string msgInfo = ((IPlugin)plugins[ListItems.SelectedIndex]).OnShowInfo();[/color] MessageBox.Show(msgInfo, "MYPlugin1", MessageBoxButtons.OK, MessageBoxIcon.Information);rn rn else if (itemStr == "MyDlg")//调用存储在动态数组plugins里面的插件<em>对象</em>的OnShowDlg方法rn rn [color=#FF0000]((IPlugin)plugins[ListItems.SelectedIndex]).OnShowDlg();[/color] rn rn elsern MessageBox.Show("请先选择列表框里的插件项", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);rn rn[/code]rnrn[code=C#]namespace Plugsrnrn public class MyConsole : IPluginrn rn public void OnShowDlg() rn public string OnShowInfo()rn rn return "调用了插件1的OnShowInfo方法!";rn rn rn[/code]
无法类型为“System.Windows.Forms.BindingSource”的对象强制转换类型“System.Data.DataTable”。
如题:rn把代码也贴上:rn[code=C#]rn DataTable dt = (DataTable)this.dataGridView_files.DataSource;rn[/code]rnrn如果是直接在dataGridView_files中添加加数据后,再转换就会报:<em>无法</em>将<em>类型</em>为“System.Windows.Forms.BindingSource”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Data.DataTable”。rnrn如果是从Excel中导入数据,就不会报错。rn
无法类型为“System.String[]”的对象强制转换类型“System.IConvertible
这个是一段代码的:rnrn int memberId = 0;rn int orderId = 0;rn protected void Page_Load(object sender, EventArgs e)rn rn memberId = Convert.ToInt32(GridView1.DataKeyNames);rn orderId =Convert.ToInt32(Request.QueryString["orderId"]);rn MemberDataBind();rn //OrderDataBind();rn rnrn在读取 memberId = Convert.ToInt32(GridView1.DataKeyNames); 这段代码的时候,出现异常的rn异常如下:rn "<em>无法</em>将<em>类型</em>为“System.String[]”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.IConvertible"rnrn大家帮哈忙吧!!rnrn
无法类型为“System.Xml.XmlNode[]”的对象强制转换类型“TongChengPolicyCancelData.TongChengTourPo
错误提示:rn<em>无法</em>将<em>类型</em>为“System.Xml.XmlNode[]”的<em>对象</em><em>强制转换</em>为<em>类型</em>“TongChengPolicyCancelData.TongChengTourPolicyCancelResult”。rn在C#调用java WebService 时出现的摄氏。rn求高手帮助
无法类型为“System.Data.DataSet”的对象强制转换类型“System.Data.DataTable”。
在网上找到的dataGridView数据导出到excel的代码,看了一下,明白了一点,源码如下:rn rn private void button1_Click(object sender, EventArgs e)rn rn ToExcel(dataGridView1);//调用的导出到excel方法rn rnrn //导出到excel方法rn public static void ToExcel(DataGridView grid)rn rn System.Data.DataTable mytable = (System.Data.DataTable)grid.DataSource;rn tryrn rn Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.ApplicationClass();rn int rowIndex, colIndex;rn rowIndex = 1;rn colIndex = 0;rn Microsoft.Office.Interop.Excel.Workbook xlBook = xlApp.Workbooks.Add(true);rn if (grid.Rows.Count > 0)rn rn foreach (DataGridViewColumn colu in grid.Columns)rn rn if (colu.Visible)rn rn colIndex = colIndex + 1;rn xlApp.Cells[1, colIndex] = colu.HeaderText;rn rn rn for (int row = 0; row < mytable.Rows.Count; row++)rn rn rowIndex = rowIndex + 1;rn colIndex = 0;rn for (int col = 0; col < grid.Columns.Count; col++)rn rn if (grid.Columns[col].Visible)rn rn colIndex = colIndex + 1;rn if (grid.Columns[col].CellType.Name == "DataGridViewComboBoxCell")rn xlApp.Cells[rowIndex, colIndex] = grid.Rows[row].Cells[col].FormattedValue;rn elsern xlApp.Cells[rowIndex, colIndex] = grid.Rows[row].Cells[col].Value;rn rn rn rn rn elsern rn foreach (DataColumn Col in mytable.Columns)rn rn colIndex = colIndex + 1;rn xlApp.Cells[1, colIndex] = Col.ColumnName;rn rn for (int row = 0; row < mytable.Rows.Count; row++)rn rn rowIndex = rowIndex + 1;rn colIndex = 0;rn for (int col = 0; col < mytable.Columns.Count; col++)rn rn colIndex = colIndex + 1;rn xlApp.Cells[rowIndex, colIndex] = grid.Rows[row].Cells[col].Value;rn rn rn rn xlApp.get_Range(xlApp.Cells[1, 1], xlApp.Cells[1, colIndex]).Font.Bold = true;rn xlApp.get_Range(xlApp.Cells[1, 1], xlApp.Cells[rowIndex, colIndex]).Borders.LineStyle = 1;rn xlApp.Cells.EntireColumn.AutoFit();rn xlApp.Cells.VerticalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;rn xlApp.Cells.HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter;rn xlApp.Visible = true;rn rn catch(Exception ex)rn rn MessageBox.Show("错误消息:"+ex.Message,"错误",MessageBoxButtons.OK,MessageBoxIcon.Error);rn rn rnrn但在运行时,出现 <em>无法</em>将<em>类型</em>为“System.Data.DataSet”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Data.DataTable”。的错误提示,如何解决rnrn
无法类型为“System.Web.UI.WebControls.DataControlLinkButton”的对象强制转换类型
想做一个关于修改数据库数据的表,但是使用转换一直出问题。请问一下大佬们。这里要怎么改rnrnrn[img=https://img-bbs.csdn.net/upload/201711/17/1510904583_680128.png][/img][img=https://img-bbs.csdn.net/upload/201711/17/1510904598_908780.png][/img][img=https://img-bbs.csdn.net/upload/201711/17/1510904605_656936.png][/img][img=https://img-bbs.csdn.net/upload/201711/17/1510904613_375245.png][/img]
无法类型为“DataGridViewTextBoxCell”的对象强制转换类型“TreeGridCell“
rn <em>无法</em>将<em>类型</em>为“System.Windows.Forms.DataGridViewTextBoxCell”的<em>对象</em><em>强制转换</em>为<em>类型</em>“AdvancedDataGridView.TreeGridCell”。rn rnvoid cells_CollectionChanged(object sender, System.ComponentModel.CollectionChangeEventArgs e)rn rn // Exit if there already is a tree cell for this rowrn if (_treeCell != null) return;rnrn if (e.Action == System.ComponentModel.CollectionChangeAction.Add || e.Action == System.ComponentModel.CollectionChangeAction.Refresh)rn rn TreeGridCell treeCell = null;rnrn if (e.Element == null)rn rn foreach (DataGridViewCell cell in base.Cells)rn rn if (cell.GetType().IsAssignableFrom(typeof(TreeGridCell)))rn rn treeCell = (TreeGridCell)cell; //错误出现的位置rn break;rn rnrn rn rn elsern rn treeCell = e.Element as TreeGridCell;rn rnrn if (treeCell != null) rn _treeCell = treeCell;rn rn rnrn咋回事呢?
无法类型为“System.Web.UI.LiteralControl”的对象强制转换类型“System.Web.UI.DataBoundLiteralCon
[img=https://img-bbs.csdn.net/upload/201408/22/1408680125_464172.jpg][/img]rn请各位大神能帮忙看看,怎么去解决!谢谢。。。
无法类型为“System.Int32”的对象强制转换类型“System.String”
“/”应用程序中的服务器错误。 <em>无法</em>将<em>类型</em>为“System.Int32”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.String”。 说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。  异常详细信息: System.InvalidCastException: <em>无法</em>将<em>类型</em>为“System.Int32”的<em>对象</em>强制
无法类型为“System.TimeSpan”的对象强制转换类型“System.IConvertible”
异常为:<em>无法</em>将<em>类型</em>为“System.TimeSpan”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.IConvertible”。rn希望高手帮忙改正一下错误,哭ingrn需要将用户选择的datetimepicker中的时间保存到数据库来实现和当前时间的对比,然后在保存的时间和当前时间差值为0或负数的时候将数据读出并发送符合时间条件的邮件。rn写的逻辑有点儿乱,哭ing 因为真的是弄不清楚。。。rn多谢大家了!!!!rn[code=C#]private void timer1_Tick(object sender, EventArgs e)rn rn DateTime dt=DateTime.Now ;rn string now = dt.ToShortDateString();rn DateTime dp = dateTimePicker1.Value;rn string connstr = @"Data Source=.\SQLEXPRESS;AttachDbFilename=D:\毕业设计\sendmail system\WindowsApplication1\WindowsApplication1\Database2.mdf;Integrated Security=True;User Instance=True";rn string mysql = "select * from Table2 where date='" + dateTimePicker1.Value.ToString() + "'";rn string mysql = "select * from Table2";rn SqlConnection conn = new SqlConnection(connstr);rn conn.Open();rn SqlDataAdapter adp = new SqlDataAdapter(mysql, conn);rn DataSet ds = new DataSet();rn adp.Fill(ds, "Table2");rn TimeSpan ts = dp.Subtract(dt);rn string d = ds.Tables["Table2"].Rows[0][0].ToString();rn string r = ds.Tables["Table2"].Rows[0][1].ToString();rn string s = ds.Tables["Table2"].Rows[0][2].ToString();rn string m = ds.Tables["Table2"].Rows[0][3].ToString();rn MessageBox.Show(r);rn int i = Convert.ToInt32(ts);rn if (i<= 0)rn rn MailAddress from = new MailAddress(textBoxUserName.Text);rn MailAddress to = new MailAddress(r);rn MailMessage message = new MailMessage(from, to);rn message.Subject = s;rn message.SubjectEncoding = System.Text.Encoding.UTF8;rn message.Body = m;rn message.BodyEncoding = System.Text.Encoding.UTF8;rn rnrn [/code]
无法类型为“CuteEditor.Editor”的对象强制转换类型“System.Web.UI.WebControls.TextBox”
我用的是Editor文本编辑想在DetailsView实现传值,把Editor里输入的内容传递给TEXTBOX里rnrnrnrnrnrnrnrn((TextBox)DetailsView1.Rows[2].Cells[1].Controls[0]).Text = ((TextBox)(DetailsView1.Rows[3].Cells[1].Controls[0])).ToString().Trim();rnrnrn这样打会报错rn<em>无法</em>将<em>类型</em>为“CuteEditor.Editor”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Web.UI.WebControls.TextBox”。rnrn寻求高手的帮助啊,哪位大侠能帮我来秒杀这个问题啊~
无法类型为“System.Int32”的对象强制转换类型“System.String”。
<em>无法</em>将<em>类型</em>为“System.Int32”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.String”。 rn说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 rnrn异常详细信息: System.InvalidCastException: <em>无法</em>将<em>类型</em>为“System.Int32”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.String”。rnrn源错误: rnrnrn行 23: while (sdr.Read())rn行 24: rn行 25: item.BookId = sdr.GetString(0);rn行 26: item.BookAuthor = sdr.GetString(1);rn行 27: item.Publisher = sdr.GetString(2);rn rnrn源文件: E:\BlueStarBookShop\DAL\ItemAccess.cs 行: 25 rnrn堆栈跟踪: rnrnrn[InvalidCastException: <em>无法</em>将<em>类型</em>为“System.Int32”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.String”。]rn System.Data.SqlClient.SqlBuffer.get_String() +1006415rn System.Data.SqlClient.SqlDataReader.GetString(Int32 i) +52rn BookShop.DAL.ItemAccess.GetItem(String bookId) in E:\BlueStarBookShop\DAL\ItemAccess.cs:25rn BookShop.BLL.ItemManager.GetItem(String bookId) in E:\BlueStarBookShop\BLL\ItemManager.cs:25rn BookShop.BLL.CartManager.Add(String bookId) in E:\BlueStarBookShop\BLL\CartManager.cs:67rn Cart.Page_Load(Object sender, EventArgs e) in e:\BlueStarBookShop\Web\ShoppingCart.aspx.cs:35rn System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15rn System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33rn System.Web.UI.Control.OnLoad(EventArgs e) +99rn System.Web.UI.Control.LoadRecursive() +47rn System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061rnrn rnrnrn--------------------------------------------------------------------------------rn版本信息: Microsoft .NET Framework 版本:2.0.50727.1882; ASP.NET 版本:2.0.50727.1879
无法类型为“System.Web.UI.WebControls.HyperLink”的对象强制转换类型“System.Web.UI.WebControls.
<em>无法</em>将<em>类型</em>为“System.Web.UI.WebControls.HyperLink”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Web.UI.WebControls.TextBox”。rn说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。rnrn异常详细信息: System.InvalidCastException: <em>无法</em>将<em>类型</em>为“System.Web.UI.WebControls.HyperLink”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Web.UI.WebControls.TextBox”。rnrn源错误:rnrn行 69: string empID = this.GridView1.DataKeys[e.RowIndex].Value.ToString(); rn行 70: //注意:以下cells的索引值可能会随着设计的进行发生变化,关键是正确地检测出 “公司名称”和 “联系人姓名”两个字段的索引值!!! rn行 71: string companyname = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[5].Controls[0])).Text.ToString().Trim(); rn行 72: string 联系人姓名 = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[6].Controls[0])).Text.ToString().Trim(); rn行 73: SqlConnection con = DB.createCon(); rnrnrn源文件: e:\MYASPNET\st13\Default.aspx.cs 行: 71rnrn堆栈跟踪:rnrn[InvalidCastException: <em>无法</em>将<em>类型</em>为“System.Web.UI.WebControls.HyperLink”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Web.UI.WebControls.TextBox”。]rn _Default.GridView1_RowUpdating(Object sender, GridViewUpdateEventArgs e) in e:\MYASPNET\st13\Default.aspx.cs:71rn System.Web.UI.WebControls.GridView.OnRowUpdating(GridViewUpdateEventArgs e) +139rn System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +808rn System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +855rn System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +95rn System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37rn System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +121rn System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37rn System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +125rn System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +169rn System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +9rn System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13rn System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +176rn System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563rnrn
无法类型为“personnelModel.RS_HolidayType”的对象强制转换类型“System.Data.DataRowView”。
protected void AdjustType_gv_RowDataBound(object sender, GridViewRowEventArgs e)rn rn if (e.Row.RowType == DataControlRowType.DataRow)rn rn ImageButton TempIB_Del = (ImageButton)e.Row.FindControl("lb_del");rn TempIB_Del.CommandName = "Person_del";rn TempIB_Del.CommandArgument = e.Row.RowIndex.ToString();rn TempIB_Del.Attributes.Add("onclick", "return confirm('真的删除吗?');");rnrn ImageButton TempIB_Mod = (ImageButton)e.Row.FindControl("lb_mod");rn TempIB_Mod.CommandName = "Adjust_Mod";rn TempIB_Mod.CommandArgument = e.Row.RowIndex.ToString();rn TempIB_Mod.Attributes.Add("onclick", "return confirm('真的修改吗?')");rnrnrnrn TextBox tempTr = (TextBox)e.Row.Cells[1].FindControl("F_Time");rn DataRowView tempDr = (DataRowView)e.Row.DataItem;rn [color=#FF0000]tempTr.Text = tempDr.Row["H_HolidayTime"].ToString();[/color]<em>无法</em>将<em>类型</em>为“personnelModel.RS_HolidayType”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Data.DataRowView”。rn TextBox tempTB = (TextBox)e.Row.Cells[1].FindControl("AT_Name");rn DataRowView tempDv = (DataRowView)e.Row.DataItem;rn tempTB.Text = tempDv.Row["H_Bank"].ToString();rnrn TextBox tempTa = (TextBox)e.Row.Cells[1].FindControl("S_Address");rn DataRowView tempDa = (DataRowView)e.Row.DataItem;rn tempTa.Text = tempDa.Row["H_HolidayType"].ToString();rn rn if (e.Row.RowType == DataControlRowType.Pager)rn rn Label Templb = (Label)e.Row.FindControl("Recordcount_lb");rn Templb.Text = _HolidaySet.RecordCount;rn Templb = (Label)e.Row.FindControl("Pagecount_lb");rn Templb.Text = AdjustType_gv.PageCount.ToString();rn Templb = (Label)e.Row.FindControl("abbPage_lb");rn Templb.Text = Convert.ToString(AdjustType_gv.PageIndex + 1);rn rn rnrnrnrnrnrn protected void btnSearch_Click(object sender, EventArgs e)rn rn tryrn rn RS_Person_BLL rpb = new RS_Person_BLL();rn List list = rpb.SearchHolidayType(txtHolidayTime.Text);rn if (list.Count > 0)rn rn AdjustType_gv.DataSource = list;rn AdjustType_gv.DataBind();rn rn elsern rn Tongyong.ShowError(ChkMessage_Panel, ChkMessage_lb, "你输入的搜索条件不正确!");rn rn AdjustType_gv.Visible = false;rn rn ChkMessage_Cancel_Click(sender, e);rn rn rn [color=#FF0000] catch (Exception ex)[/color] 捕获:<em>无法</em>将<em>类型</em>为“personnelModel.RS_HolidayType”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Data.DataRowView”。 rnrn Tongyong.ShowError(ChkMessage_Panel, ChkMessage_lb, "你输入的搜索条件不正确!");rn rn
无法类型为“System.Web.UI.LiteralControl”的对象强制转换类型“System.Web.UI.HtmlControls.HtmlTa
HtmlTableRow row in [color=#FF0000]((HtmlTable)this.mainContent.Controls[0]).[/color]Rowsrnrn<em>无法</em>将<em>类型</em>为“System.Web.UI.LiteralControl”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Web.UI.HtmlControls.HtmlTable”。rnrn红色为报错的地方 请问怎么转换成HtmlTable
无法类型为“LoginCustomControl.WebCustomControl”的对象强制转换类型“System.ComponentModel.Design.IDesigner”
我照着书上的例子做了一个练习,发现发生如下错误,大家帮我看看。rn自定义了一个用户登陆的控件,代码如下:rnusing System;rnusing System.Collections.Generic;rnusing System.ComponentModel;rnusing System.Text;rnusing System.Web;rnusing System.Web.UI;rnusing System.Web.UI.WebControls;rnrnusing System.Web.UI.Design;rnrnnamespace LoginCustomControlrnrn /// rn /// LoginCustomControl 的摘要说明rn /// rn [rn ParseChildren(true),rn Description("Login Control"),rn Designer(typeof(LoginCustomControl.WebCustomControl)),rn ToolboxData("")rn ]rn public class WebCustomControl : WebControl, INamingContainerrn rn private static string USERNAME_STRING = "用户名:";rn private static string PASSWORD_STRING = "密 码:";//两个字中间留空格rn private static string LOGIN_STRING = "登录";rn private static string RESET_STRING = "重置";rn private static string CAPTION_STRING = "用户登录";rn private static string REGISTER_STRING = "注册新用户";rnrn private TextBox tbUsername;rn private TextBox tbPassword;rn private Button btnLogin;rn private Button btnReset;rn private LiteralControl vUserName;rn private LiteralControl vPassword;rn private LinkButton lbRegister;rn private bool _show_register;rnrnrn public event EventHandler Login;rn public event EventHandler Reset;rn public event EventHandler Register;rnrn protected void OnLogin(EventArgs e)rn rn if (Login != null)rn rn Login(this, e);rn rn rnrn protected void OnReset(EventArgs e)rn rn if (Reset != null)rn rn Reset(this, e);rn rn rnrn protected void OnRegister(EventArgs e)rn rn if (Register != null)rn rn Register(this, e);rn rn rn public string UserNamern rn getrn rn this.EnsureChildControls();rn return tbUsername.Text;rn rn setrn rn this.EnsureChildControls();rn tbUsername.Text = value;rn rn rnrn public string Passwordrn rn getrn rn this.EnsureChildControls();rn return tbPassword.Text;rn rn setrn rn this.EnsureChildControls();rn tbPassword.Text = value;rn rn rnrn [rn Browsable(true),rn Category("Behaviour"),rn Description("是否显示注册新用户链接")rn ]rnrn public bool ShowRegisterrn rn getrn rn return _show_register;rn rn setrn rn _show_register = value;rn rn rn protected override void CreateChildControls()rn rn base.CreateChildControls();rnrn //文本rn string str = @" ";rn str += @" " + CAPTION_STRING + "";rn str += @" ";rn str += @" ";rn str += @" ";rn str += USERNAME_STRING;rn str += " ";rn this.Controls.Add(new LiteralControl(str));rnrn //用户名输入框rn tbUsername = new TextBox();rn tbUsername.Text = "";rn tbUsername.Width = Unit.Point(80);rn tbUsername.MaxLength = 64;rn tbUsername.Attributes.Add("size", "11");rn this.Controls.Add(tbUsername);rnrn //验证rn vUserName = new LiteralControl("*");rn vUserName.Visible = false;rn this.Controls.Add(vUserName);rnrn //文本rn str = @" ";rn str += PASSWORD_STRING;rn str += " ";rn this.Controls.Add(new LiteralControl(str));rnrn //密码输入框rn tbPassword = new TextBox();rn tbPassword.Text = "";rn tbPassword.Width = Unit.Point(80);rn tbPassword.MaxLength = 64;rn tbPassword.Attributes.Add("size", "11");rn tbPassword.TextMode = TextBoxMode.Password;rn this.Controls.Add(tbPassword);rnrnrn //验证rn vPassword = new LiteralControl("*");rn vPassword.Visible = false;rn this.Controls.Add(vPassword);rnrn //文本rn str = @" ";rn this.Controls.Add(new LiteralControl(str));rnrn //注册新用户链接rn if (ShowRegister)rn rn lbRegister = new LinkButton();rn lbRegister.Text = REGISTER_STRING;rn lbRegister.ToolTip = REGISTER_STRING;rn lbRegister.Click += new EventHandler(lbRegister_Click);rn this.Controls.Add(lbRegister);rnrn //文本rn str = " ";rn this.Controls.Add(new LiteralControl(str));rn rnrn //登录按钮rn btnLogin = new Button();rn btnLogin.Text = LOGIN_STRING;rn btnLogin.ToolTip = LOGIN_STRING;rn btnLogin.Click += new EventHandler(btnLogin_Click);rn this.Controls.Add(btnLogin);rnrn //文本rn str = " ";rn this.Controls.Add(new LiteralControl(str));rnrn //重置按钮rn btnReset = new Button();rn btnReset.Text = RESET_STRING;rn btnReset.ToolTip = RESET_STRING;rn btnReset.Click += new EventHandler(btnReset_Click);rn this.Controls.Add(btnReset);rnrn //文本rn str = "";rn this.Controls.Add(new LiteralControl(str));rn rnrn private void btnLogin_Click(object sender, EventArgs e)rn rn bool b = true;rn if (UserName.Trim() == "")rn rn vUserName.Visible = true;rn b = false;rn rn if (Password.Trim() == "")rn rn vPassword.Visible = true;rn b = false;rn rn if (b)rn rn OnLogin(EventArgs.Empty);rn rn rn private void btnReset_Click(object sender, EventArgs e)rn rn this.UserName = "";rn this.Password = "";rn OnReset(EventArgs.Empty);rn rn private void lbRegister_Click(object sender, EventArgs e)rn rn OnRegister(EventArgs.Empty);rn rn rnrn /// rn /// 设计器类rn /// rn public class LoginControlDesign : ControlDesignerrn rn public override string GetDesignTimeHtml()rn rn return @" Login Control";rn rn rnrn将它添加到一个页面中去的时候,不能显示属性页,提示WebCustomControl1:<em>无法</em>将<em>类型</em>为“LoginCustomControl.WebCustomControl”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.ComponentModel.Design.IDesigner”.
无法类型为“System.Web.UI.WebControls.Button”的对象强制转换类型“System.Web.UI.WebControls.TextBox”????
[img=http://p14.freep.cn/p.aspx?u=v20_p14_p_0808021131554697_0.jpg][/img]rnrn protected void Dgd_manger_UpdateCommand(object source, DataGridCommandEventArgs e)rnrn rn rn SqlCommand cm = new SqlCommand("update_user",cn);rn cm.CommandType = CommandType.StoredProcedure;rnrn //cm.Parameters.Add(new SqlParameter("@UserName",SqlDbType.VarChar,50));rn cm.Parameters.Add(new SqlParameter("@UseType", SqlDbType.Int));rn TextBox2.Text = ((TextBox)e.Item.Cells[1].Controls[0]).Text;rn string colvalue = TextBox2.Text.ToString();rn //string colvalue = (e.Item.Cells[1].Controls[0]).ToString();rn //cm.Parameters["@UserName"].Value = colvalue;rn //colvalue = ((TextBox)e.Item.Cells[1].Controls[0]).Text;rn //colvalue = (e.Item.Cells[2].Controls[0]).ToString();rn cm.Parameters["@UseType"].Value = colvalue;rn //cm.Parameters["@UserName"].Value=Dgd_manage.DataKeys[(int)e.Item.ItemIndex];rn cm.Connection.Open();rn tryrn rn cm.ExecuteNonQuery();rn Response.Write(" ");rn Dgd_manage.EditItemIndex = -1;rn rn catch (SqlException)rn rn Response.Write(" ");rn rn cm.Connection.Close();rn Bindgrid();rn rnrnrn我做一个数据库的更新,总是在更新时出现如题错误,就必一个字段UserType.rn最初是,string colvalue = (e.Item.Cells[1].Controls[0]).ToString();rn同样是这个错误,我加了个文本框来传值也不行,请问:我该怎么办?
无法类型为“System.Windows.Controls.Button”的对象强制转换类型“SilverlightApplication4.MACAddr
using System;rnusing System.Collections.Generic;rnusing System.Linq;rnusing System.Net;rnusing System.Windows;rnusing System.Windows.Controls;rnusing System.Windows.Documents;rnusing System.Windows.Input;rnusing System.Windows.Media;rnusing System.Windows.Media.Animation;rnusing System.Windows.Shapes;rnusing System.Runtime.InteropServices.Automation;rnrnnamespace SilverlightApplication4rnrn public partial class MainPage : UserControlrn rn // public MainPage()rn //rn // InitializeComponent();rn // rnrn public MainPage()rn rn InitializeComponent();rn MACAddressManager macAddressManager = new MACAddressManager();rn macAddressManager.OnGetMACAddressCompleted +=rn new EventHandler(macAddressManager_OnGetMACAddressCompleted);rn macAddressManager.BeginGetMACAddress();rnrnrn rnrn void macAddressManager_OnGetMACAddressCompleted(object sender, EventArgs e)rn rn [color=#FF0000]MACAddressManager manager = (MACAddressManager) sender;[/color] // MAC Address value is in manager.MACAddressrn//<em>无法</em>将<em>类型</em>为“System.Windows.Controls.Button”的<em>对象</em><em>强制转换</em>为<em>类型</em>“SilverlightApplication4.MACAddressManager”。rnrnrn MessageBox.Show(manager.MACAddress);rn rnrn rnrn private void button1_Click_1(object sender, RoutedEventArgs e)rn rn this.macAddressManager_OnGetMACAddressCompleted(sender, e);rn rn rnrn public class MACAddressManagerrn rn private dynamic sWbemServices;rn private dynamic sWbemSink;rnrn public string MACAddress get; private set; rn public event EventHandler OnGetMACAddressCompleted;rnrn private void EndGetMACAddress(object sender, EventArgs e)rn rn dynamic objWbemObject = sender;rn MACAddress = objWbemObject.MACAddress;rn if (OnGetMACAddressCompleted != null)rn OnGetMACAddressCompleted(this, EventArgs.Empty);rn rnrn public void BeginGetMACAddress()rn rn if ((Application.Current.IsRunningOutOfBrowser) &&rn(Application.Current.HasElevatedPermissions) && (AutomationFactory.IsAvailable))rn rn dynamic sWbemLocator = AutomationFactory.CreateObjectrn("WbemScripting.SWBemLocator");rn sWbemServices = sWbemLocator.ConnectServer(".");rn sWbemServices.Security_.ImpersonationLevel = 3; //impersonaternrn sWbemSink = AutomationFactory.CreateObject("WbemScripting.SWbemSink");rn sWbemSink.OnObjectReady += new EventHandler(EndGetMACAddress);rnrn string query =rn"SELECT * FROM Win32_NetworkAdapterConfiguration where IPEnabled=true";rn sWbemServices.ExecQueryAsync(sWbemSink, query);rn rn rnrnrnrn rnrnrnrn高手帮忙解决一下呀 这个获得客户端 MAC地址的实例 我调试不好 rn在网上找的 始终弄不好 rn我是个初学者 谢谢了
无法类型为“System.Int32”的对象强制转换类型“System.Array”
修改Edit.cshtml上部分字段,点击保存跳转到Index.cshtml。n但现在点击保存,就跳出以下错误。nn![图片说明](https://img-ask.csdn.net/upload/201508/23/1440271095_308679.jpg)nnn**这是Model **nn```n using System;nusing System.Collections.Generic;nusing System.ComponentModel;nusing System.ComponentModel.DataAnnotations;nusing System.ComponentModel.DataAnnotations.Schema;nusing System.Linq;nusing System.Web;nnnamespace MvcSilverTalent.Modelsnn public class RetireeModeln n [Key]n [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]n public int RetireNum get; set; nn [Required]n [DisplayName("单位编号")]n [MaxLength(3)]n public string UnitID get; set; nn [Required]n [DisplayName("员工编号")]n [MaxLength(6)]n public string EmployeeID get; set; nn [Required]n [DisplayName("离退休<em>类型</em>")]n public int RetireType get; set; nn [Required]n [DisplayName("删除标记")]n public int DeleteFlag get; set; nnn //n // 基本信息nnn [Required]n [DisplayName("姓名")]n [MaxLength(20)]n public string Name get; set; nn [Required]n [DisplayName("性别")]n public Boolean Gender get; set; nn [Required]n [DisplayName("身份证号码")]n public string IDCardNo get; set; nn [Required]n [DisplayName("出生年月")]n public DateTime Brityday get; set; nn [Required]n [DisplayName("民族")]n [MaxLength(30)]n public string Nationality get; set; nn [Required]n [DisplayName("籍贯")]n [MaxLength(30)]n public string NativePlace get; set; nn [DisplayName("党派")]n [MaxLength(30)]n public string Party get; set; nn [DisplayName("所在党支部")]n [MaxLength(100)]n public string PartyBranch get; set; nn [DisplayName("最高学历")]n [MaxLength(20)]n public string EducationDegree get; set; nn [Required]n [DisplayName("用户组")]n public string GroupName get; set; nn [Required]n [DisplayName("是否参加爱心基金")]n public Boolean HasLoveFund get; set; nn [DisplayName("享受爱心基金慰问情况")]n public string LoveFundCase get; set; nn [DisplayName("慰问走访情况")]n public string VisitCase get; set; nnn //n // 工作信息nnn [Required]n [DisplayName("参加工作时期")]n public int WorkPeriod get; set; nn [Required]n [DisplayName("参加工作时间")]n public DateTime WorkTime get; set; nn [Required]n [DisplayName("退休时间")]n public DateTime RetireTime get; set; nn [Required]n [DisplayName("工龄")]n public int WorkAge get; set; nn [Required]n [DisplayName("退休单位")]n [MaxLength(100)]n public string UnitName get; set; nn [DisplayName("职称代码")]n [MaxLength(3)]n public int TitleID get; set; nn [DisplayName("职称")]n [MaxLength(30)]n public string Title get; set; nn [DisplayName("职务")]n [MaxLength(30)]n public string Position get; set; nn [DisplayName("编制")]n [MaxLength(30)]n public string Formation get; set; nnn //n // 可修改信息 nnn [Required]n [MaxLength(255)]n [DisplayName("近照")]n public string PhotoUrl get; set; nn [MaxLength(255)]n [DisplayName("特长")]n public string Specialty get; set; nn [Required]n [MaxLength(255)]n [DisplayName("现住地址")]n public string Address get; set; nn [MaxLength(30)]n [DisplayName("家庭电话")]n public string HomeTel get; set; nn [MaxLength(30)]n [DisplayName("手机号码")]n public string MobileNum get; set; nn [MaxLength(10)]n [DisplayName("邮政编码")]n public string ZipCode get; set; nn [MaxLength(40)]n [DisplayName("邮箱")]n public string Email get; set; nnn public virtual ICollection EventSignModels get; set; n public virtual ICollection HealthSignMains get; set; n nnn```nn**这是controller **nn```nn // GET: /UserInfo/Edit.cshtmlnn public ActionResult Edit(int RetireNum) n n RetireeModel RetireeModel = db.RetireeModels.Find(RetireNum);n if (RetireeModel == null)n n return HttpNotFound();n n return View(RetireeModel);n nnn //n // POST: /UserInfo/Edit.cshtmlnn [HttpPost]n [ValidateAntiForgeryToken]n public ActionResult Edit(RetireeModel RetireeModel)n n Response.Write(" ");nn if (ModelState.IsValid)n n db.Entry(RetireeModel).State = EntityState.Modified;n n db.SaveChanges();n return RedirectToAction("Index");n n Response.Write(" ");nn return View("Index");n nn```nnn
无法类型为“System.IO.UnmanagedMemoryStream”的对象强制转换类型“System.IO.MemoryStream”。
/// rn /// Creates a new AlphaImage from the given resource name.rn /// rn /// AlphaImage image = AlphaImage.CreateFromResource("AlphaMobileControls.TestApp.Resources.Wallpaper.jpg");rn /// rn /// rn public static AlphaImage CreateFromResource(string imageResourceName)rn rnrn return CreateFromStream((MemoryStream)Assembly.GetCallingAssembly().GetManifestResourceStream(imageResourceName));rn rnrn不能强转,有间接的转换方法么?求大家指点
无法类型为“System.TimeSpan”的对象强制转换类型“System.IConvertible”。
float fine;rn today = (System.DateTime.Now.Date).ToString();//获取系统当前日期rn DateTime t = Convert.ToDateTime(today);//将当前日期转换成日期<em>类型</em>rn DateTime s = Convert.ToDateTime(Session["shdate"]);//取出应还书的日期rn rnrn if (t>s)//比较是否超期rn rn isexpire = "是";rn fine = Convert.ToInt32(t-s) * (int)this.Session["dfine"];//计算罚款金额,Session["dfine"]表示取出每天罚款金额rn conn.Close();rnrn rn elsern rn isexpire = " 否";rn fine=0;rn conn.Close();rn rn错误提示:rn<em>无法</em>将<em>类型</em>为“System.TimeSpan”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.IConvertible”。rnrn是不是因为t-s的结果是TimeSpan <em>类型</em>,不能直接转换为Int32?rn如果不能,那要求出总罚款金额,应该如何转换呢?rn另外t-s能求出连个日期的相差天数吗?
无法类型为“System.Web.UI.LiteralControl”的对象强制转换类型
用GridView时,有用“编辑”,点“更新”后出现错误:rn<em>无法</em>将<em>类型</em>为“System.Web.UI.LiteralControl”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Web.UI.WebControls.DropDownList”。 rnrnrn string templateid = ((DropDownList)Gvw_List.Rows[e.RowIndex].Cells[2].Controls[0]).SelectedValue;
无法类型为“System.Data.DataTable”的对象强制转换类型“MXDataTable”。
<em>无法</em>将<em>类型</em>为“System.Data.DataTable”的<em>对象</em><em>强制转换</em>为<em>类型</em>“MXDataTable”。 ado.net,声明的有 MXDataTable,我2表联合查询得出 DataTable,在页面上修改后,我拆分了DataTable,然后把DataTable 转化为MXDataTable ,但是提示<em>无法</em>转换。。。急急急。。。
无法类型为“Newtonsoft.Json.Linq.JObject”的对象强制转换类型“Newtonsoft.Json.Linq.JArray”。
纯小白;rn在写一个短信发送,用的别人的模板,然后发现报这个错误,是不能这么转吗?rnpublic static JArray strToObj(string str)rn rn JArray json = (JArray)JsonConvert.DeserializeObject(str);rn return json; rn
无法类型为“System.Web.UI.LiteralControl”的对象强制转换类型“System.Web
它的错误原因和底下的一样,我就直接复制、粘贴了。   <em>无法</em>将<em>类型</em>为“System.Web.UI.LiteralControl”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Web.UI.WebControls.DropDow转老韩的:解决System.Web.UI.LiteralControl (2009-04-02 18:02:53) 1.解释什么是System.Web.UI.LiteralCont
无法类型为“System.Xml.XmlComment”的对象强制转换类型“System.Xml.XmlElement”。
private void UpdateElement()     {         LoadXml();         XmlNodeList nodeList = xmlDoc.SelectSingleNode("/configuration/appSettings").ChildNodes;//获取appSettings节点的所有子节点         foreach (XmlNode x
无法类型为“Oracle.DataAccess.Client.OracleParameter”的对象强制转换类型
<em>无法</em>将<em>类型</em>为“Oracle.DataAccess.Client.OracleParameter”的<em>对象</em><em>强制转换</em>为<em>类型</em>“Oracle.DataAccess.Client.OracleParameter”。 Oracle.DataAccessIDbDataParameter[] dbParameters 以接口方...
无法类型为“System.Data.DataView”的对象强制转换类型“System.Data.DataTable”
c# <em>无法</em>将<em>类型</em>为“System.Data.DataView”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Data.DataTable”rn((DataTable)dataGridView1.DataSource).Rows.Add(strArray); 就是这句提示的错误请高手指教
无法类型为“System.Data.DataRowView”的对象强制转换类型“QualityControl.Model.T_ROL_Regulatory”
[code=C#]protected void ReList_ItemDataBound(object sender, RepeaterItemEventArgs e)rn rn if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)rn rn rn ((Label)e.Item.FindControl("LaReal")).Text = ((QualityControl.Model.T_ROL_Regulatory)e.Item.DataItem).RealName;rn rn [/code]rn上面的是代码,我是仿照公司以前项目的写法写的,但是到我这就报错了。。实在是找不到原因[img=http://hi.csdn.net/attachment/201103/8/3867_12995454634HX8.jpg][/img]
无法类型为“Rs_Sysyem.Models.RS_Person”的对象强制转换类型“System.Data.DataRowView”。
protected void Attendance_gv_RowDataBound(object sender, GridViewRowEventArgs e)rn rn if (e.Row.RowType == DataControlRowType.DataRow)rn rn ImageButton temp_edit = (ImageButton)e.Row.FindControl("lb_edit");rn temp_edit.CommandName = "Attendance_Edit";rn temp_edit.CommandArgument = e.Row.RowIndex.ToString();rnrnrn [color=#FF0000] Label temp_tab = (Label)e.Row.FindControl("a_status_m");rn DataRowView temp_dv = (DataRowView)e.Row.DataItem;rn temp_tab.Text = AttendanceClass.ShowStatus(temp_dv.Row["a_status_m"].ToString());rnrnrn Label temp_tab_A = (Label)e.Row.FindControl("a_status_a");rn DataRowView temp_dv_A = (DataRowView)e.Row.DataItem;rn temp_tab_A.Text = AttendanceClass.ShowStatus(temp_dv_A.Row["a_status_a"].ToString());[/color] /////<em>无法</em>将<em>类型</em>为“Rs_Sysyem.Models.RS_Person”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Data.DataRowView”。rn if (e.Row.RowType == DataControlRowType.Pager)rn rn Label Templb = (Label)e.Row.FindControl("Recordcount_lb");rn Templb.Text = _AttendanceManage.RecordCount;rn Templb = (Label)e.Row.FindControl("Pagecount_lb");rn Templb.Text = Attendance_gv.PageCount.ToString();rn Templb = (Label)e.Row.FindControl("abbPage_lb");rn Templb.Text = Convert.ToString(Attendance_gv.PageIndex + 1);rn rn
无法类型为“System.Runtime.Remoting.ObjectHandle”的对象强制转换类型“System.Web.IHttpHandler”
<em>无法</em>将<em>类型</em>为“System.Runtime.Remoting.ObjectHandle”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Web.IHttpHandler”。 rn说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 rnrn异常详细信息: System.InvalidCastException: <em>无法</em>将<em>类型</em>为“System.Runtime.Remoting.ObjectHandle”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Web.IHttpHandler”。rnrn源错误: rnrnrn行 39: case "aspx":rn行 40: object obj = Activator.CreateInstance(a.FullName, "HttpHandlerLibrary.HttpHandler1");rn行 41: handler = (IHttpHandler)obj;rn行 42: break;rn行 43: case "ashx":rn rnrn源文件: e:\dotnet\WebSite5\App_Code\MyHttpHandlerFactory.cs 行: 41 rnrnrn附上我的源代码:rnusing System;rnusing System.Collections.Generic;rnusing System.Linq;rnusing System.Web;rnusing HttpHandlerLibrary;rnusing System.Reflection;rnrn/// rn///MyHttpHandlerFactory 的摘要说明rn/// rnpublic class MyHttpHandlerFactory:IHttpHandlerFactoryrnrn public MyHttpHandlerFactory()rn rn //rn //TODO: 在此处添加构造函数逻辑rn //rn rnrn #region IHttpHandlerFactory 成员rnrn public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated)rn rn string fileType = url.Substring(url.LastIndexOf(".")+1);rn IHttpHandler handler=null;rn Assembly a;rn tryrn rn a = Assembly.Load("HttpHandlerLibrary");rn rn catch (Exception e)rn rnrn Console.Write(e.Message);rn throw e;rn rn switch (fileType)rn rn case "aspx":rn object obj = Activator.CreateInstance(a.FullName, "HttpHandlerLibrary.HttpHandler1");rn[color=#FF0000] handler = (IHttpHandler)obj;[/color]rn break;rn case "ashx":rn obj = Activator.CreateInstance(a.FullName, "HttpHandlerLibrary.HttpHander2");rn[color=#FF0000] handler = (IHttpHandler)obj;[/color]rn break;rn default:rn break;rn rn return handler;rn rnrn public void ReleaseHandler(IHttpHandler handler)rn rn throw new NotImplementedException();rn rnrn #endregionrnrnrnHttpHandler1.cs的源代码:rnusing System;rnusing System.Collections.Generic;rnusing System.Linq;rnusing System.Text;rnusing System.Web;rnrnnamespace HttpHandlerLibraryrnrn class HttpHandler1:IHttpHandlerrn rn #region IHttpHandler 成员rnrn public bool IsReusablern rn get return true; rn rnrn public void ProcessRequest(HttpContext context)rn rn context.Response.Write("From HttpHandler1 class ");rn context.Response.Write("HttpHandlerFacoty Test ");rn rnrn #endregionrn rnrn
无法类型为“System.Data.DataTable”的对象强制转换类型“System.Data.DataSet
dbCmdBuilder = new OleDbCommandBuilder(dbAdapter);rnDataSet ds = new DataSet();rnds = (System.Data.DataSet)DataGridView实例.DataSource;rndbAdapter.Update(ds);rnrn提示<em>无法</em>将<em>类型</em>为“System.Data.DataTable”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Data.DataSet”rnrnrn请问该怎样修改上面的代码?
无法类型为LiteralControl的对象强制转换类型.Label
我的代码:rn int index = 0;rn for ( index = 0; index < this.panel.Controls.Count; index++)rn rn if (this.panel.Controls[index].ID==Session["vote"].ToString())rn rn Response.Write(this.panel.Controls[index].ID);rn _Label lab = (Label)this.panel.Controls[index];_rn sum++;rn break;rn rnrn rn int j = 0;rn for (j=0; j < this.panel.Controls.Count; j++)rn rn if (j == index + 1)rn rn Response.Write(this.panel.Controls[j].ID);rn _Label lab = (Label)this.panel.Controls[j];_rn Response.Write(lab.ID);rn lab.Text = (Double.Parse(lab.Text) + 1).ToString();rn //Response.Redirect("VoteResult.aspx");rn rn rn 问题:第一个<em>强制转换</em>label就没有毛病,第二个就出错,为什么?怎么解决这个问题?
无法类型为“ASP._Page_Views_Transport_Quarantine_cshtml”的对象强制转换类型“System.Web.IHttpHa
<em>无法</em>将<em>类型</em>为“ASP._Page_Views_Transport_Quarantine_cshtml”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Web.IHttpHandler”。rnrn说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 rnrn异常详细信息: System.InvalidCastException: <em>无法</em>将<em>类型</em>为“ASP._Page_Views_Transport_Quarantine_cshtml”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Web.IHttpHandler”。rnrn源错误: rnrn执行当前 Web 请求期间生成了未经处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。rnrn堆栈跟踪: rnrnrn[InvalidCastException: <em>无法</em>将<em>类型</em>为“ASP._Page_Views_Transport_Quarantine_cshtml”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Web.IHttpHandler”。]rn System.Web.WebPages.WebPageHttpHandler.CreateFromVirtualPath(String virtualPath, VirtualPathFactoryManager virtualPathFactoryManager) +56rn System.Web.WebPages.WebPageRoute.DoPostResolveRequestCache(HttpContextBase context) +264rn System.Web.WebPages.WebPageHttpModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) +89rn System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136rn System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
无法类型为“System.Windows.Forms.Button”的对象强制转换类型“System.Windows.Forms.Form”
这段代码中:rnrnforeach (Control ctl in ((Form)sender).Controls)rn rn RadioButton rb = new RadioButton();rn if (ctl.GetType().Name == "radioButton1")rn rn rb = (RadioButton)ctl;rn MessageBox.Show(rb.Name.ToString());rn rn rn rnrnforeach (Control ctl in ((Form)sender).Controls)这句在程序运行时会出现rn<em>无法</em>将<em>类型</em>为“System.Windows.Forms.Button”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.Windows.Forms.Form”错误,这是什么原因?应该如何改啊?
无法对象强制转换类型
rn if (application.Session != null && application.Session["UserEntity"] != null)rnrn DataEntity.T_UserEntity user = (DataEntity.T_UserEntity)application.Session["UserEntity"];rn}rnrn<em>无法</em>将<em>类型</em>为“System.Security.Principal.WindowsPrincipal”的<em>对象</em><em>强制转换</em>为<em>类型</em>“DataEntity.T_UserEntityrn这个问题怎么解决啊
C#.NET开发Winform使用MySQL数据库 无法将“System.Byte[]”的对象强制转换类型“System.IConvertible”
C#.NET 3.5开发winform程序,后台使用的是MySQL 5.1.x 数据库rn从MySQL官网下的 mysql-connector-net-6.5.4,安装后在.NET里使用正常,使用MySqlConnection,MySqlCommand操作的数据库,自己写了一个MySqlHelper.cs,里面有一个执行MySqlCommand的方法用于更新数据rn[code=C#]private const string connectString = "server=127.0.0.1;uid=root;pwd=root;database=dbname";rnpublic static bool MysqlExcute(MySqlCommand cmd)rnrn MySqlConnection conn = new MySqlConnection(connectString);rn conn.Open();rn cmd.Connection = conn;rn int rtn = cmd.ExecuteNonQuery();rn conn.Close();rn return rtn > 0;rn[/code]rn数据库的pic表中有一个longblob字段pic_data,存储图片数据rn现在在程序中获得了图片的路径path,下面的程序执行后,会在MySqlExcute方法中的ExecuteNonQuery那句话上报错rn<em>无法</em>将“System.Byte[]”的<em>对象</em><em>强制转换</em>为<em>类型</em>“System.IConvertible”rn[code=C#] // 读取图片内容rn FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);rn Byte[] imgByte = new Byte[fs.Length]; rn fs.Read(imgByte, 0, imgByte.Length);rnrn // 插入图片rn MySqlCommand cmd = new MySqlCommand("INSERT INTO pic(pic_data, upload_username, upload_datetime) " +rn "VALUES(?pic_name, ?pic_data, ?upload_username, ?upload_datetime)");rn cmd.Parameters.AddWithValue("?pic_name", pic_name);rn cmd.Parameters.AddWithValue("?pic_data", MySqlDbType.VarBinary).Value = imgByte;rn cmd.Parameters.AddWithValue("?upload_username", Session.username);rn cmd.Parameters.AddWithValue("?upload_datetime", DateTime.Now.ToString());rn if (MySqlHelper.MysqlExcute(cmd))rn rn // 上传成功rn // ...rn rn elsern rn // ...rn [/code]rn查了很多貌似没有遇到我这种情况的,想请大家帮忙看看,谢谢各位啦 :D
C++沉思录和源代码(完整版)下载
C++沉思录和源代码(完整版) 非常经典的书 相关下载链接:[url=//download.csdn.net/download/wwq100/2430634?utm_source=bbsseo]//download.csdn.net/download/wwq100/2430634?utm_source=bbsseo[/url]
右键调整图片大小win7版下载
它可以很方便的批量缩小图片,安装完后只要按右键就可以将你喜欢的图缩小,同时保证图片质量,特别的是,支持Win7! 相关下载链接:[url=//download.csdn.net/download/zhouguanyou/3058485?utm_source=bbsseo]//download.csdn.net/download/zhouguanyou/3058485?utm_source=bbsseo[/url]
我编程我快乐(英文版)下载
我编程我快乐(英文版) PDF 我编程我快乐(英文版) 相关下载链接:[url=//download.csdn.net/download/guolong1983811/4918883?utm_source=bbsseo]//download.csdn.net/download/guolong1983811/4918883?utm_source=bbsseo[/url]
相关热词 c#单元测试入门 c# 数组转化成文本 c#实体类主外键关系设置 c#ocrt能识别中文吗 c# 子函数 局部 c#窗口位置设置 c# list 查询 c# 事件 执行顺序 c# 不同数据库 创建表 c# tcp通信客户端类
我们是很有底线的