【发布时间】:2015-06-26 00:18:06
【问题描述】:
我想根据我的数据集填充我的文本框。
DAL
public static DataTable GetCustomer(collection b)
{
{
DataTable table;
try
{
string returnValue = string.Empty;
DB = Connect();
DBCommand = connection.Procedure("getCustomer");
DB.AddInParameter(DBCommand, "@CustomerRef", DbType.String, b.CustomerRef1);
DbDataReader reader = DBCommand.ExecuteReader();
table = new DataTable();
table.Load(reader);
return table;
}
catch (Exception ex)
{
throw (ex);
}
}
}
BLL
public DataSet returnCustomer(collection b)
{
try
{
SqlDataAdapter adapt = new SqlDataAdapter();
DataSet table = new DataSet();
adapt.Fill(table, "table");
return table;
}
catch (Exception ex)
{
throw ex;
}
}
PL
protected void ddl_Customers_SelectedIndexChanged(object sender, EventArgs e)
{
DAL.collection cobj = new collection();
BLL.business bobj = new business();
string selectedValue = ddl_Customers.SelectedValue.ToString();
//populate the text boxes
txtCustomerRef.Text = bobj.returnCustomer(cobj);
}
我收到一个错误:
无法将类型“System.Data.DataSet”隐式转换为“字符串”
当我填充我的文本框时,我需要从数据集中获取特定值,这应该是客户参考。但我看不出我做错了什么?
【问题讨论】:
-
您的
returnCustomer返回DataSet但您尝试将其返回值分配给txtCustomerRef.Text这是一个string并且这两种类型之间没有隐式对话。考虑改变你的逻辑。 -
@SonerGönül:您能否建议更改答案?
标签: c# asp.net webforms data-access-layer 3-tier