Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 在列表框中列出搜索结果_Asp.net_Vb.net_Search_Listbox_Telerik - Fatal编程技术网

Asp.net 在列表框中列出搜索结果

Asp.net 在列表框中列出搜索结果,asp.net,vb.net,search,listbox,telerik,Asp.net,Vb.net,Search,Listbox,Telerik,对于新管理员。在我的应用程序中,有一个GridView来显示数据库中的记录 有一个文本框,允许用户输入员工姓名,然后单击“搜索”按钮。我想在列表框中显示搜索结果(显示类似的员工姓名)。当用户单击名称时,它将自动插入数据库,然后刷新GridView 如何基于文本框对列表框进行数据绑定?当用户单击列表框时,如何插入值?谢谢 <%@ Page Language="VB" AutoEventWireup="false" CodeFile="ITAlert.aspx.vb" Inherits="De

对于新管理员。在我的应用程序中,有一个
GridView
来显示数据库中的记录

有一个
文本框
,允许用户输入员工姓名,然后单击“搜索”按钮。我想在
列表框中显示搜索结果(显示类似的员工姓名)。当用户单击名称时,它将自动插入数据库,然后刷新
GridView

如何基于
文本框
列表框
进行数据绑定?当用户单击列表框时,如何插入值?谢谢

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="ITAlert.aspx.vb" Inherits="DepartmentManager_ITAlert" %>     
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title></title>
</head>

<body>
  <form id="form1" runat="server">
    <div style="width: 500px; margin-left: auto; margin-right: auto;">
      <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
      </telerik:RadScriptManager>
      <asp:Label ID="Label1" runat="server" 
                 Text="Staffs to get the email alert:" 
                 Font-Bold="true"></asp:Label>
      <br /><br />  
      <telerik:RadGrid ID="RadGrid1" runat="server" AllowSorting="True"
                       allowpaging="true" AutoGenerateColumns="False"
                       DataSourceID="LDS" GridLines="None"  pagesize="20"
                       AllowAutomaticDeletes="True" 
                       Style="border: 0; outline: none;"
                       OnDeleteCommand="RadGrid1_DeleteCommand">
        <ClientSettings AllowColumnsReorder="True" 
                        ReorderColumnsOnClient="True">
          <Selecting AllowRowSelect="True" />
        </ClientSettings>
        <MasterTableView DataSourceID="LDS" DataKeyNames="ID">
          <CommandItemSettings ExportToPdfText="Export to Pdf">
          </CommandItemSettings>
          <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
            <HeaderStyle Width="20px"></HeaderStyle>
          </RowIndicatorColumn>
          <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
            <HeaderStyle Width="20px"></HeaderStyle>
          </ExpandCollapseColumn>
          <Columns>
            <telerik:GridBoundColumn DataField="DisplayName"
                                     FilterControlAltText="Filter Name column"
                                     HeaderText="Staff Name" ReadOnly="True"
                                     SortExpression="DisplayName"
                                     UniqueName="DisplayName">
            </telerik:GridBoundColumn>                
            <telerik:GridButtonColumn ConfirmText="Delete this record?"
                                      ConfirmDialogType="RadWindow"
                                      ConfirmTitle="Delete" 
                                      ButtonType="ImageButton" Text="Delete"
                                      CommandName="Delete" />
          </Columns>
          <EditFormSettings>
            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
            </EditColumn>
          </EditFormSettings>
        </MasterTableView>
        <FilterMenu EnableImageSprites="False">
        </FilterMenu>
        <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
        </HeaderContextMenu>
      </telerik:RadGrid>
      <asp:LinqDataSource ID="LDS" runat="server" 
                          ContextTypeName="DataContext"
                          OrderBy="DisplayName" Select="new (ID, DisplayName)"
                          TableName="v_EmailAlerts" Where="Type == 4">
        <WhereParameters>
          <asp:QueryStringParameter Name="CID" QueryStringField="CID"
                                    Type="Int32" />
        </WhereParameters>       
      </asp:LinqDataSource>
      <br />
      <br />
      <asp:TextBox runat="server" ID="tb_staffname">
      </asp:TextBox>
      <asp:Button ID="btnSearch" runat="server" Text="Search"
                  OnClick="btnSearch_click"/>
      <telerik:RadListBox runat="server" ID="RadListBox_staff" Height="300px"
                          Width="230px" AllowTransfer="false" 
                          AutoPostBack="false" 
                          style="top: 0px; left: 0px" 
                          DataSourceID="LDS_staff"
                          DataTextField="displayname" DataValueField="sid" >
      </telerik:RadListBox>
      <asp:LinqDataSource ID="LDS_staff" runat="server"
                          ContextTypeName="dcHRISDataContext"
                          OrderBy="DisplayName" Select="new (SID, DisplayName)"
                          TableName="vHRIS_StaffDBs"
                          Where="Lefe == False and SID is nothing">   
      </asp:LinqDataSource>                
   </div>
 </form>
</body>
</html>

让事情变得简单一点。。。使用如下条目将编辑表单移动到用户控件中:

<EditFormSettings EditFormType="WebUserControl" UserControlName="adminLookup.ascx">

adminLookup.ascx
中添加一个绑定到您希望能够查找的用户列表的。然后,您应该能够在独立的用户控件中轻松调试和解决查找查询的任何问题

此功能的演示可在此处找到:

首先,在发布代码片段时,请花一点时间对其进行格式化-至少要删除大量空白。其次,在LINQ语句中出现了什么错误?
Dim rec = (From a In dc.vHRIS_StaffDBs Where a.Lefe = False _
           And (x >= x.DisplayName.Matches(sname)) Select a.SID, _
           a.DisplayName Order By DisplayName).ToList
<EditFormSettings EditFormType="WebUserControl" UserControlName="adminLookup.ascx">