我正在设计一个基于网络的物流系统。在我的视图订单页面中,我有一些绑定到数据源的下拉列表和旁边的网格视图。当操作员选择相关的下拉列表时,我想更改网格视图数据源。我写了代码,但它不工作,网格视图不显示任何数据。请告诉我我做错了什么。
//Code for firing drop down list event
public void ddlVehicleFire(Object sender, EventArgs e)
{
GridView1.DataSource = VehicleDastaSource;
GridView1.DataBind();
}
//aspx页面
<asp:SqlDataSource ID="VehicleDastaSource" runat="server" ConnectionString="<%$ ConnectionStrings:LGDB %>" SelectCommand="SELECT [vehicleID], [manufacturer], [VIN], [capacity], [weight_], [dateOfProduction] FROM [vehicle]"></asp:SqlDataSource>
Drop down list
asp:DropDownList ID="DDLVehicle" runat="server" DataSourceID="vehicle" DataTextField="vehicleID" DataValueField="vehicleID" AutoPostBack="True" OnSelectedIndexChanged="ddlVehicleFire"></asp:DropDownList>