我在 asp.net 中工作,我有三个文本框(名字、姓氏、中间名缩写)。有一个列表视图,根据输入到文本框中的信息显示内容。我试图只需要姓氏文本框来处理信息。我已经使用以下代码将 sql 数据源连接到列表视图:
<asp:TabPanel runat="server" HeaderText="Information" ID="TabPanel">
<ContentTemplate>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ Name of the database %>"
SelectCommand="SELECT [UserID], [UserSuffix], [UserAddressLine1], [UserAddressLine2], [UserCity],
[UserState], [UserZipCode], [UserPhoneNumber], [UserEmail] FROM [AllUsers]
WHERE (([UserLastName] = @UserLastName) OR ([UserFirstName] = @UserFirstName)
OR ([UserMiddleInitial] = @UserMiddleInitial))">
<SelectParameters>
<asp:ControlParameter ControlID="txtUILastName" Name="UserLastName"
PropertyName="Text" />
<asp:ControlParameter ControlID="txtUIFirstName" Name="UserFirstName"
PropertyName="Text" />
<asp:ControlParameter ControlID="txtUIMI" Name="UserMiddleInitial"
PropertyName="Text" />
</SelectParameters>
</asp:SqlDataSource>
<table id = "USERINF">
<tr>
<td width="196px" class="style8">
<asp:Label ID="lblFirstName" runat="server" Text="Please enter First Name:"></asp:Label>
</td>
<td class="style6">
<asp:TextBox ID="txtUIFirstName" runat="server" MaxLength="20"></asp:TextBox>
</td>
</tr>
<tr>
<td width="196px" class="style8">
<asp:Label ID="lblLastName" runat="server" Text="Please enter Last Name:"></asp:Label>
</td>
<td class="style6">
<asp:TextBox ID="txtUILastName" runat="server" MaxLength="20"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate = "txtUILastName" ValidationExpression = "[a-zA-Z ]{1,20}"
ForeColor="Red" ValidationGroup="UserInf"
ErrorMessage="First Name must be only a-z,A-Z characters!" Display="Dynamic"></asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate = "txtUILastName" ErrorMessage="Please enter Last Name!"
ForeColor="Red" ValidationGroup="UserInf" Display="Dynamic"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td width="196px" class="style8">
<asp:Label ID="lblMI" runat="server" Text="Please enter Middle Initials:"></asp:Label>
</td>
<td class="style6">
<asp:TextBox ID="txtUIMI" runat="server" MaxLength="1" Width="30px" style="text-align: center;
margin-left:2px"></asp:TextBox>
</td>
</tr>
<tr>
<td width="196px" class="style8">
</td>
<td class="style6">
<asp:Button ID="btnIFind" runat="server" Text="Find" ValidationGroup = "UserInf"/>
当我只输入姓氏时,它不会从数据源中检索任何数据,但只有在我填写所有文本框时才有效。我怎样才能只需要一个文本框来检索信息?
查找按钮和文本框后面没有任何代码