Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用c在Asp.Net中实现多列DropDownList_C#_Asp.net_Sql - Fatal编程技术网

C# 使用c在Asp.Net中实现多列DropDownList

C# 使用c在Asp.Net中实现多列DropDownList,c#,asp.net,sql,C#,Asp.net,Sql,我试图在下拉列表菜单中显示2列。为此, 当我在SSMS中执行以下sql查询时 从成本标识中选择convertvarchar、成本标识+、'+项目描述 它带来了期望的输出。但当我将其添加到Microsoft Visual Studio 2012数据源中时 当我运行程序时,会出现以下错误: 数据绑定:“System.Data.DataRowView”不包含名为“Cost\u ID”的属性 知道我哪里出错了吗 谢谢。您的SQL语句没有为转换操作提供列名: SelectCommand="SELECT (

我试图在下拉列表菜单中显示2列。为此,

当我在SSMS中执行以下sql查询时

从成本标识中选择convertvarchar、成本标识+、'+项目描述

它带来了期望的输出。但当我将其添加到Microsoft Visual Studio 2012数据源中时

当我运行程序时,会出现以下错误:

数据绑定:“System.Data.DataRowView”不包含名为“Cost\u ID”的属性

知道我哪里出错了吗


谢谢。

您的SQL语句没有为转换操作提供列名:

SelectCommand="SELECT (convert(varchar,CostID) +' , '+ Item_Description) FROM Cost_ID"
将其更改为:

SelectCommand="SELECT (convert(varchar,CostID) +' , '+ Item_Description) Cost_ID FROM Cost_ID"