我正在使用.net
应用程序,我有一个单选按钮列表,需要从我的数据库中的表中填充。我能够获取数据并将它们添加到列表但事实是,当在浏览器中显示时,它显示utility.closingReason
而不是来自数据库的数据,这是您在我的内容中可以看到的类的名称码。
知道我做错了吗?提前谢谢
protected void rblContentTypesGetReasons_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
ArrayList list = new ArrayList();
string sqlQuery;
sqlQuery = " SELECT REASON_DESCRIPTION";
sqlQuery += " FROM CLOSING_REASON";
dt = clsUtility.GetDataTableFromDB(sqlQuery, null);
if (dt.Rows.Count != 0)
{
foreach (DataRow row in dt.Rows)
{
objReason = getReason(dt);
//for (int i = 0; i < dtReturn.Rows.Count; i++)
list.Add(objReason);
//RadioBtnReasons.Items.Add(new ListItem(dtReturn.Rows[i]["reason_description"].ToString() ));
}
}
RadioBtnReasons.DataSource = list;
RadioBtnReasons.DataBind();
//RadioBtnReasons.Items.Clear();
}
这是我用来从数据库中获取数据的代码。
和方法:
private object getReason(DataTable dt)
{
closingReason reason = new closingReason(dt);
return reason;
}
和班级closingReason
namespace Utility
{
class closingReason
{
private System.Data.DataTable dt;
private string _REASON_DESCRIPTION;
public string REASON_DESCRIPTION
{
get { return _REASON_DESCRIPTION; }
set { _REASON_DESCRIPTION = value; }
}
public closingReason(System.Data.DataTable dt)
{
// TODO: Complete member initialization
REASON_DESCRIPTION = dt.Rows[0]["reason_description"].ToString();
}
}
}