当我将下拉列表与两列连接时,我无法提取 sql 数据。我想结合姓氏(lName)+名字(fName)并提取这些名字的数据。这是我到目前为止所拥有的。
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
DataSourceID="SqlDataSource3" DataTextField="lName" DataValueField="lName"
AppendDataBoundItems="True"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Value="Select">Select</asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStrings:TestDBConnectionString1 %>"
SelectCommand="SELECT (lName + fName) AS zName FROM CoaTest"></asp:SqlDataSource>
然后我有一个包含所有 Databounds 的 formview,它的 sql 连接如下所示:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:TestDBConnectionString1 %>"
DeleteCommand="DELETE FROM [CoaTest] WHERE [Id] = @Id"
SelectCommand="SELECT Id, fName, lName, agency, title, gen, hired, AppS,
course, Location, SessNum, SDate, EDate, Hours, SitUps, pushUps, rTime,
Grade FROM CoaTest WHERE (lName = @lName)"
UpdateCommand="UPDATE [CoaTest] SET [fName] = @fName, [lName] = @lName, [agency] = @agency, [title] = @title, [gen] = @gen, [hired] = @hired, [AppS] = @Apps, [course] = @course, [Location] = @Location, [SDate] = @SDate, [EDate] = @EDate, [Hours] = @Hours WHERE [Id] = @Id">
<DeleteParameters>
<asp:Parameter Name="Id" Type="Int32" />
</DeleteParameters>
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="lName"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="fName" Type="String" />
<asp:Parameter Name="lName" Type="String" />
<asp:Parameter Name="Agency" Type="String" />
<asp:Parameter Name="title" />
<asp:Parameter Name="gen" />
<asp:Parameter Name="hired" />
<asp:Parameter Name="Apps" />
<asp:Parameter Name="course" />
<asp:Parameter Name="Location" />
<asp:Parameter Name="SDate" />
<asp:Parameter Name="EDate" />
<asp:Parameter Name="Hours" />
<asp:Parameter Name="Id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
如果我只是按姓氏 (lName) 拉取它,则此方法有效,但是当我尝试连接时,它不会从表单视图中拉取数据。先感谢您!!