CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  .NET技术 >  ASP.NET

从vb改成c#的语句提示错误。

楼主hiweiyi2000(胖子)2005-07-20 09:22:42 在 .NET技术 / ASP.NET 提问

在vb.net:  
    DataSource='<%#   FilterProducts(   Container.DataItem(   "CategoryID"   )   )%>'  
  为什么,在C#这样写:  
    DataSource='<%#   FilterProducts(DataBinder.Eval(Container.DataItem,"CategoryID"))%>'  
  就提示错误 问题点数:20、回复次数:15Top

1 楼hiweiyi2000(胖子)回复于 2005-07-20 09:27:17 得分 0

编译错误    
  说明:   在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。    
   
  编译器错误信息:   CS1502:   与“ASP.NestedRowFilter_aspx.FilterProducts(int)”最匹配的重载方法具有一些无效参数  
   
  源错误:  
   
     
   
  行   43:   <ItemTemplate>  
  行   44:   <h2><%#DataBinder.Eval(Container.DataItem,   "CategoryName"   )%></h2>  
  行   45:   <asp:DataGrid  
  行   46:       DataSource='<%#FilterProducts(DataBinder.Eval(Container.DataItem,   "CategoryID"   ))   %>'  
  行   47:       Runat="Server"   />  
     
   
  源文件:   G:\note\s\NestedRowFilter.aspx         行:   45    
  Top

2 楼hdt(倦怠)回复于 2005-07-20 09:30:44 得分 10

public   FilterProducts(   string   strid   )  
  {  
        int   nid   =   int.parse(strid);  
  .....  
   
  }Top

3 楼chengbo1983(chengbo.net)回复于 2005-07-20 09:35:19 得分 0

同上Top

4 楼hiweiyi2000(胖子)回复于 2005-07-20 09:45:04 得分 0

<%@   Page   Language="C#"   %>  
  <%@   Import   Namespace="System.Data"   %>  
  <%@   Import   Namespace="System.Data.SqlClient"   %>  
   
  <script   runat=server>  
  DataSet   dstNorthwind;  
  DataView   dvwProducts;  
   
  void   Page_Load(Object   sender   ,   EventArgs   e)    
  {  
  SqlConnection   conNorthwind;  
  SqlDataAdapter   dadNorthwind;  
   
  dstNorthwind   =   new   DataSet();  
  conNorthwind   =   new   SqlConnection(   @"Server=localhost;UID=sa;PWD=weiYI10;Database=Northwind"   );  
  dadNorthwind   =   new   SqlDataAdapter(   "Select   *   From   Categories",   conNorthwind   );  
  dadNorthwind.Fill(   dstNorthwind,   "Categories"   );  
  dadNorthwind.SelectCommand   =   new   SqlCommand(   "Select   *   From   Products",   conNorthwind   );  
  dadNorthwind.Fill(   dstNorthwind,   "Products"   );  
  dvwProducts   =   dstNorthwind.Tables[   "Products"   ].DefaultView;  
   
  rptCategories.DataSource   =   dstNorthwind;  
  rptCategories.DataMember   =   "Categories";  
  rptCategories.DataBind();  
  }  
   
   
  DataView   FilterProducts(   int   intCatID   )  
  {  
  dvwProducts.RowFilter   =   "CategoryID="   +   intCatID;  
  return   dvwProducts;  
  }  
   
  </Script>  
   
  <html>  
  <head><title>NestedRowFilter.aspx</title></head>  
  <body>  
   
  <asp:Repeater  
      ID="rptCategories"  
      Runat="Server">  
  <ItemTemplate>  
  <h2><%#DataBinder.Eval(Container.DataItem,   "CategoryName"   )%></h2>  
  <asp:DataGrid  
      DataSource='<%#FilterProducts(DataBinder.Eval(Container.DataItem,   "CategoryID"   ))   %>'  
      Runat="Server"   />  
  </ItemTemplate>  
  </asp:Repeater>  
   
  </body>  
  </html>  
   
  我按上面的做了,但是没有解决问题。  
  将源码全上。Top

5 楼hdt(倦怠)回复于 2005-07-20 09:54:38 得分 10

DataView   FilterProducts(   string   strId   )  
  {  
                  int       intCatId   =   int.parse(strId);  
  dvwProducts.RowFilter   =   "CategoryID="   +   intCatID;  
  return   dvwProducts;  
  }  
  Top

6 楼hiweiyi2000(胖子)回复于 2005-07-20 10:01:05 得分 0

编译错误    
  说明:   在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。    
   
  编译器错误信息:   CS0117:   “int”并不包含对“parse”的定义  
   
  源错误:  
   
     
   
  行   28:   DataView   FilterProducts(   string   strId   )  
  行   29:   {  
  行   30:                   int       intCatId   =   int.parse(strId);  
  行   31:   dvwProducts.RowFilter   =   "CategoryID="   +   intCatID;  
  行   32:   return   dvwProducts;  
     
   
  源文件:   G:\note\s\NestedRowFilter.aspx         行:   30    
  Top

7 楼hiweiyi2000(胖子)回复于 2005-07-20 10:01:27 得分 0

还没有解决。  
  错误提示如上。Top

8 楼jimu8130(火箭的未来在哪里?)回复于 2005-07-20 10:51:22 得分 0

如果你用convert。toint32()?Top

9 楼kongxing(我心飞翔)回复于 2005-07-20 10:59:14 得分 0

应该是C#中区分大小写的问题吧Top

10 楼hiweiyi2000(胖子)回复于 2005-07-20 11:47:35 得分 0

按照Convert.ToInt32  
  做了,不解决问题。  
  要求大家能实际动行调试过一次。  
  Top

11 楼hiweiyi2000(胖子)回复于 2005-07-20 17:36:22 得分 0

顶一下。  
  Top

12 楼webdiyer(.net资源精华—www.dotneturls.com)回复于 2005-07-20 17:59:41 得分 0

DataSource='<%#   FilterProducts(int.Parse(DataBinder.Eval(Container.DataItem,"CategoryID")).ToString())%>'  
  这样也可以Top

13 楼hdt(倦怠)回复于 2005-07-21 05:17:15 得分 0

陕北的方法好  
  Top

14 楼hiweiyi2000(胖子)回复于 2005-07-21 11:06:28 得分 0

用了陕北的方法还是提示错误:  
   
  编译错误    
  说明:   在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。    
   
  编译器错误信息:   CS1502:   与“int.Parse(string)”最匹配的重载方法具有一些无效参数  
   
  源错误:  
   
     
   
  行   43:   <ItemTemplate>  
  行   44:   <h2><%#DataBinder.Eval(Container.DataItem,   "CategoryName"   )%></h2>  
  行   45:   <asp:DataGrid  
  行   46:       DataSource='<%#   FilterProducts(int.Parse(DataBinder.Eval(Container.DataItem,"CategoryID")).ToString())%>'  
  行   47:    
     
  Top

15 楼webdiyer(.net资源精华—www.dotneturls.com)回复于 2005-07-21 17:37:05 得分 0

Sorry,括号位置错了,应该是:  
   
  DataSource='<%#   FilterProducts(int.Parse(DataBinder.Eval(Container.DataItem,"CategoryID").ToString()))%>Top

相关问题

  • ---------------------请问这个C#的语句怎样改成VB的---------------------???
  • ---------------------请问这个C#的语句怎样改成VB的---------------------???
  • 一句vb语句转C#
  • 怎样将这条语句改成vb下的语句
  • 怎样将这条pb语句改成vb下的语句
  • vb里的dao语句都改成ado,怎么改?
  • 在vb中使用sql语句,如何给属性和表改成别名?
  • 请问C#中有没有象Vb中的with语句那样的语句吗?
  • 谁帮我把这条vb语句转换成c#语句,谢谢,在线等
  • 请将下面的C#语句转换成VB。NET语句,谢谢!就一句

关键词

  • c#

得分解答快速导航

  • 帖主:hiweiyi2000
  • hdt
  • hdt

相关链接

  • CSDN .NET频道
  • .NET类图书
  • C#类图书
  • .NET类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo