Array List值未绑定到Gridview,它总是返回消息:
名称为' CUSTOMER_NAME'的字段或媒体资源未在所选数据源中找到。
我有GridView作为
<asp:GridView ID="GdVClient" runat="server"
AllowPaging="True"
CellPadding="4"
ForeColor="#333333"
GridLines="Vertical"
Style="width: 700px; height: auto;">
<Columns>
<asp:BoundField DataField="CUSTOMER_NAME" />
</Columns>
</asp:GridView>
DisplayCustomer.aspx.cs:
protected void GetCustomer(object sender, EventArgs e)
{
CutomerService cs = new CutomerService();
ArrayList alCustomer = cs.GetCustomerDetail();
GdVClient.DataSource = alCustomer;
GdVClient.DataBind();
}
CutomerService.cs:
[WebMethod(Description = "GetCustomerDetail1")]
public ArrayList GetCustomerDetail()
{
DataSet dsCustomer = new DataSet();
Hashtable htDetails = new Hashtable();
ArrayList alDetails = new ArrayList();
String sqlCustomer = "SELECT [CUSTOMER_NAME]FROM [SAMPLE].[dbo]. [CUSTOMER]";
dsCustomer = SqlHelper.ExecuteDataset(SampleProjectConn.SPConn, CommandType.Text, sqlCustomer);
foreach(DataRow row in dsCustomer.Tables[0].Rows)
{
htDetails = new Hashtable();
foreach(DataColumn col in dsCustomer.Tables[0].Columns)
{
htDetails.Add(Convert.ToString(col.ColumnName), Convert.IsDBNull(row[col.ColumnName]) ? string.Empty : Convert.ToString(row[col.ColumnName]));
}
alDetails.Add(htDetails);
}
return alDetails;
}
如何将值绑定到GridView?请帮忙。谢谢。