C# 文本框文本的GridView更新已更改
我想为C# 文本框文本的GridView更新已更改,c#,asp.net,gridview,webforms,C#,Asp.net,Gridview,Webforms,我想为GridView数据创建实时搜索,因此我尝试了以下代码: 我在aspx文件中有这个: <asp:ScriptManager ID="DateManager" runat="server" /> <asp:UpdatePanel ID="setDate" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true"> <C
GridView
数据创建实时搜索,因此我尝试了以下代码:
我在aspx
文件中有这个:
<asp:ScriptManager ID="DateManager" runat="server" />
<asp:UpdatePanel ID="setDate" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:TextBox ID="gro" runat="server" Width="73px" />
<asp:TextBox ID="job" runat="server" Width="94px" />
<asp:TextBox ID="username" runat="server" Width="98px" />
<asp:TextBox ID="lname" runat="server" Width="123px" />
<asp:TextBox ID="fname" runat="server" Width="78px"
ontextchanged="fname_TextChanged" AutoPostBack="True" />
<asp:GridView ID="res" runat="server" AutoGenerateColumns="False"
CellPadding="4" ForeColor="#333333" GridLines="None" Width="600px"
AllowPaging="True" DataKeyNames="id">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:CommandField SelectText="selectIt" ShowSelectButton="True" />
<asp:BoundField DataField="fname" HeaderText="First Name" />
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="fname" EventName="TextChanged" />
</Triggers>
</asp:UpdatePanel>
当我输入fname
时,GridView
不会改变,但当我在GridView
中单击selectIt时,它会显示搜索结果。试试这个
if (re != null)
{
res.DataSource = re;
res.DataBind();
}
试试这个
if (re != null)
{
res.DataSource = re;
res.DataBind();
}
设置网格视图的属性EnableViewState=“false”
<asp:GridView ID="res" runat="server" EnableViewState="False" >