0
私は顧客情報を表示するグリッドビューを持っています。ユーザーが最初と最後のどちらかの名前をテキストボックスに入力すると結果が更新されます。基本的に、グリッドビューへのデータバインディングには、ユーザータイプとしてのテキストボックスからの更新された文字を使用したデータソースです。DataBind GridView OnKeyUp/Down
CODE EDITED:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Process.aspx.cs" Inherits="Reservations.WebForm3" %>
<asp:UpdateProgress ID="UpdateProgress1" runat="server"
AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>Processing...</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="firstname" runat ="server" class="inputLarge" ontextchanged="firstname_TextChanged" />
<asp:TextBox ID="lastname" runat="server" class="inputLarge" />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="457px">
<Columns>
<asp:TemplateField>
<EditItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</EditItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:BoundField DataField="CustID" HeaderText="Cust ID">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="FirstName" HeaderText="First Name">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="LastName" HeaderText="Last Name">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="City" HeaderText="City">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
</Columns>
</asp:GridView>
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts></Scripts>
</asp:ScriptManager>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="firstname" EventName="TextChanged" />
</Triggers>
</asp:UpdatePanel>
protected void firstname_TextChanged(object sender, EventArgs e)
{
InventoryAppSoapClient inst = new InventoryAppSoapClient();
DataSet ds = inst.getCustomer(firstname.Text, "none");
GridView1.DataSource = ds;
GridView1.DataBind();
}
すべては初回のみ、初めてTextChangedイベントを除いて動作します。私が戻ってテキストとタブを変更すると、何も起こりません。
私はそれを考えましたが、ユーザタイプとしてグリッドを更新したいと思います。 onTextChangedは、テキストボックスのフォーカスが失われるまで発生しません。 onKeyUpとonKeyDownイベントを使用してJavaScriptやJQueryでバインドする方法はありますか? – jmease
私はあなたの提案をしていますが、gridviewはfirstname_OnTextChanged()イベントのexisting.DataBind()呼び出しに応答しません。データソースを設定するときにクエリをテストしたので、結果が返されるはずです。 gridviewが最初は空だったので、多分苦労していますか? – jmease
グリッドビューは更新パネルにありますか? – gsirianni