Asp.net 操作员'+';未为类型';列表项';和字符串“&引用;
我试着把下面的课文放在这里,所以它基本上是Product1,Product2,Product3等等。。。此外,如果会话包含文本“选择…”以将其替换为“”,则当我运行下面的代码时,得到的错误运算符“+”没有为类型“ListItem”和字符串“,”定义Asp.net 操作员'+';未为类型';列表项';和字符串“&引用;,asp.net,vb.net,Asp.net,Vb.net,我试着把下面的课文放在这里,所以它基本上是Product1,Product2,Product3等等。。。此外,如果会话包含文本“选择…”以将其替换为“”,则当我运行下面的代码时,得到的错误运算符“+”没有为类型“ListItem”和字符串“,”定义 您试图将对象连接在一起,请改为: NameofProduct = Session("Product1").ToString() + "," + Session("Product2").ToString().Replace("Select....",
您试图将
对象连接在一起,请改为:
NameofProduct = Session("Product1").ToString() + "," + Session("Product2").ToString().Replace("Select....", "") + "," + Session("Product3").ToString() + "," + Session("Product4").ToString() + "," + Session("ProductManual").ToString()
您试图将对象连接在一起,请改为:
NameofProduct = Session("Product1").ToString() + "," + Session("Product2").ToString().Replace("Select....", "") + "," + Session("Product3").ToString() + "," + Session("Product4").ToString() + "," + Session("ProductManual").ToString()
IMO try Session(“Product1”).ToString()在连接的所有部分中;您会发现它们并不都是字符串…IMO try Session(“Product1”).ToString()在连接的所有部分;您会发现它们并不都是字符串…出于可维护性的考虑,请使用StringBuilder:
Dim sb as new StringBuilder
sb.AppendFormat("{0},", Session("Product1"))
sb.AppendFormat("{0},", Session("Product2").Replace("Select....", ""))
sb.AppendFormat("{0},", Session("Product3"))
sb.AppendFormat("{0},", Session("Product4"))
sb.AppendFormat("{0}", Session("ProductManual")
NameofProduct = sb.ToString()
为了便于维护,请使用StringBuilder:
Dim sb as new StringBuilder
sb.AppendFormat("{0},", Session("Product1"))
sb.AppendFormat("{0},", Session("Product2").Replace("Select....", ""))
sb.AppendFormat("{0},", Session("Product3"))
sb.AppendFormat("{0},", Session("Product4"))
sb.AppendFormat("{0}", Session("ProductManual")
NameofProduct = sb.ToString()
只是好奇你试过&
操作符吗
NameofProduct = Session("Product1") & "," & Session("Product2").Replace("Select....", "") & "," & Session("Product3") & "," & Session("Product4") & "," & Session("ProductManual")
试一试只是好奇你试过&
操作符吗
NameofProduct = Session("Product1") & "," & Session("Product2").Replace("Select....", "") & "," & Session("Product3") & "," & Session("Product4") & "," & Session("ProductManual")
试试看它的vb.net,因为没有;在这行的末尾,也是在C中,您将有会话[“Product1”],而不是会话(“Product1”),它的vb.net原因是没有;在这行的末尾,也是在C语言中,您将有会话[“Product1”],而不是会话(“Product1”)