1

如何将 sqldatasource 默认值设置为数据库字段值。我有一个像这样的编码,

<asp:DropDownList ID="ddVehicle" runat="server"  AppendDataBoundItems="true" CssClass="drop" DataSourceID="SqlDataSource4" DataTextField="VehicleType" DataValueField="VehicleId">
                <asp:ListItem Value="">-Select-</asp:ListItem>
            </asp:DropDownList>
            <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:TAXIConnectionString %>" SelectCommand="SELECT [VehicleId], [VehicleType] FROM [VehicleMaster] WHERE ([VehicleId] = @Vehicle or [Status] = @Status1)">
                 <SelectParameters>
                    <asp:Parameter DefaultValue="???" Name="Vehicle" Type="String" />
                     <asp:Parameter DefaultValue="Available" Name="Status1" Type="String" />
                </SelectParameters>
            </asp:SqlDataSource>    

帮我。

4

1 回答 1

1

尝试这个:

 SqlDataSource4.SelectParameters.Add("@Vehicle", "Vehicle Value");
于 2013-05-14T18:31:27.483 回答