【发布时间】:2019-12-11 00:50:16
【问题描述】:
我正在处理一个项目,我想在其中显示客户的所有事件信息(来自数据库)(我从文本框/用户输入中获取)。
我正在努力填充 ListBox,但我不确定到目前为止我是否有正确的想法来使用“RowFilter”函数。
public partial class CustomerSurvey : System.Web.UI.Page
{
private Incident incidentInformation;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnGet_Incidents(object sender, EventArgs e)
{
incidentInformation = this.GetInfoForSelectedCustomerID();
}
private Incident GetInfoForSelectedCustomerID()
{
//get row from AccessDataSource based on value in dropdownlist
DataView customersTable = (DataView)
SqlDataSource2.Select(DataSourceSelectArguments.Empty);
customersTable.RowFilter =
"CustomerID = '" + txtCustomerID_ForIncidents + "'";
DataRowView row = (DataRowView)customersTable[0];
//create a new product object and load with data from row
Incident i = new Incident();
i.IncidentID = (int)row["IncidentID"];
i.CustomerID = (int)row["CustomerID"];
i.ProductCode = row["ProductCode"].ToString();
i.TechID = (int)row["TechID"];
i.DateOpened = (DateTime)row["DateOpened"];
i.DateClosed = (DateTime)row["DateClosed"];
i.Title = row["Title"].ToString();
i.Description = row["Description"].ToString();
return i;
}
private void DisplayInfo()
{
Incident incident = (Incident)Session["Reservation"];
lstCustomers.Display
}
正如您在上面看到的,函数 DisplayInfo 尚未完成。这是因为我不知道如何填充 ListBox。
我正在考虑的另一件事是,客户可能会遇到多起事件,我不确定我在课堂上的方法是否正确。
谢谢!
【问题讨论】:
标签: c# asp.net .net visual-studio