2010-04-18 39 views
0

我有下拉列表,我想通过存储过程 填充数据从数据库,它具有它,s值当特定查询字符串我有两个查询字符串。查询字符串填充下拉列表

作为

私人无效LoadWithCategory() { 如果(的Request.QueryString [ “CATEGORY_ID”]!= NULL){ 使用 (SqlConnection的CON = Connection.GetConnection()){

  SqlCommand Com = new SqlCommand("GetProducFamilyTP", Con); 
      Com.CommandType = CommandType.StoredProcedure; 
      Com.Parameters.Add(Parameter.NewInt("@Category_Id", Request.QueryString["Category_Id"])); 
      SqlDataReader DR = Com.ExecuteReader(); 


      if (DR.Read()) 
      { 
       DDLProductFamily.DataSource = DR; 
       DDLProductFamily.DataTextField = DR["Name"].ToString(); 
       DDLProductFamily.DataValueField = DR["ProductCategory_Id"].ToString(); 

       DDLProductFamily.DataBind(); 

      } 
      DR.Close(); 
     } 
    } 
} 

ALTER PROC GetProducFamilyTP ( @Category_Id诠释 ) AS SELECT DISTINCT Categories.Category_Id,ProductCategory.Name, ProductCategory.ProductCategory_Id 从Category_ProductCategory

内加入分类 在 Category_ProductCategory.Category_Id = Categories.Category_Id 内部联接产品分类 在 Category_ProductCategory.ProductCategory_Id = ProductCategory.ProductCategory_Id Where Categories.Indd = @ Category_Id

但发生此错误

DataBinding:'System.Data.Common.DataRecordInternal'不包含名称为'4Door'的属性。

+0

重复? http://stackoverflow.com/questions/2645639/fill-dropdown-list-by-querystring – 2010-04-18 09:20:17

+0

但错误我无法解决它,我提到了它 – Myworld 2010-04-18 11:02:40

+0

检查你的程序和你的表 - 错误说清楚,无法找到'4门' – Aristos 2010-04-18 14:00:18

回答

0

错误是在ddl列表中,当我删除它它运作良好它有价值= 0