我有一个从存储过程中读取的列表。它只是一个选择语句。我不知道为什么会收到错误消息“在所选数据源中找不到字段或属性名称 'Ticket ID'。” 我正在做的是用我的代码和预定义的列填充 gridview。
public List<SelectQueuedTickets> GetQueuedTickets()
{
List<SelectQueuedTickets> QueuedTicketsList = new List<SelectQueuedTickets>();
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
{
using (SqlCommand com = new SqlCommand("[Reader].[usp_SelectQueuedTickets]", con))
{
con.Open();
com.CommandType = CommandType.StoredProcedure;
SqlDataReader rd = com.ExecuteReader();
while (rd.Read())
{
this.TicketID = Convert.ToString(rd["Ticket ID"]);
this.PriorityID = Convert.ToInt32(rd["Priority"]);
this.FormType = Convert.ToString(rd["Form Type"]);
this.Summary = Convert.ToString(rd["Summary"]);
this.CreationDate = Convert.ToDateTime(rd["Creation Date"]);
this.OwnerGroup = Convert.ToString(rd["Owner Group"]);
this.Owner = Convert.ToString(rd["Owner"]);
this.Creator = Convert.ToInt32(rd["Creator"]);
this.AffectedUser = Convert.ToInt32(rd["Affected User"]);
this.OwnerEmail = Convert.ToString(rd["Owner Email"]);
this.AffectedUserEmail = Convert.ToString(rd["Affected User Email"]);
QueuedTicketsList.Add(this);
}
}
}
return QueuedTicketsList;
}
protected void LoadQueuedTickets()
{
SelectQueuedTickets selectqueuedtickets = new SelectQueuedTickets();
GridView1.DataSource = selectqueuedtickets.GetQueuedTickets();
GridView1.DataBind();
}