我使用背后的代码和Postback调用方法。用文本框编写Ado.net点击搜索ID,它会根据ID给我数据。
我想使用AJAX加载或执行相同的工作,并重新获得xml
请看一下我的代码:
公共无效GetArtikelByNavisionID() { 字符串CS = ConfigurationManager.ConnectionStrings [“ LagerLogistikConnectionString”]。ToString();
using (SqlConnection connection = new SqlConnection(CS))
{
connection.Open();
SqlCommand command = new SqlCommand("Here is the Query for example select Id =@Id", connection);
command.Parameters.AddWithValue("Id ", TextSearch.Text);
DataTable dt = new DataTable();
SqlDataAdapter adapter = new SqlDataAdapter(command);
adapter.Fill(dt);
GridArtikel_Information.DataSource = dt;
GridArtikel_Information.DataBind();
}
}
HTML:
<div class="row">
<div class="col-lg-12 align-self-end ">
<div class="form-group">
<asp:Button ID="BtnSuche" CssClass="btn btn-primary btn-block" AutoPostBack="true" OnClick="Title_SetFocus_Click" runat="server" Text="Suche" />
</div>
</div>
</div>
<div class="col-lg-12">
<asp:TextBox ID="TextSearch" CssClass="form-control" runat="server"></asp:TextBox>
</div>
<div class="row" style="margin-top: 10px;">
<dx:ASPxGridView ID="GridArtikel_Information"
AutoGenerateColumns="false"
EnableRowsCache="true"
KeyFieldName="NavisionID"
SettingsPager-PageSize="15"
SettingsPager-Mode="ShowPager"
Width="100%"
runat="server">
<Settings ShowHeaderFilterButton="true" />
<Columns>
<dx:GridViewCommandColumn ShowNewButtonInHeader="false" ShowEditButton="false" Visible="false">
</dx:GridViewCommandColumn>
<dx:GridViewDataColumn Caption="Barcode" FieldName="Barcode">
</dx:GridViewDataColumn>
<dx:GridViewDataColumn Caption="P_Name" FieldName="P_Name">
</dx:GridViewDataColumn>
<dx:GridViewDataColumn Caption="NavisionID" FieldName="NavisionID">
</dx:GridViewDataColumn>
<dx:GridViewDataColumn Caption="P_KreditorNr" FieldName="P_KreditorNr">
</dx:GridViewDataColumn>
<dx:GridViewDataColumn Caption="Farbe" FieldName="Farbe">
</dx:GridViewDataColumn>
<dx:GridViewDataColumn Caption="Größe" FieldName="Größe">
</dx:GridViewDataColumn>
<dx:GridViewDataColumn Caption="Unit_Name" FieldName="Unit_Name">
</dx:GridViewDataColumn>
<dx:GridViewDataColumn Caption="Lagername" FieldName="Lagername">
</dx:GridViewDataColumn>
<dx:GridViewDataColumn Caption="IstAufgebaut" FieldName="IstAufgebaut">
</dx:GridViewDataColumn>
</Columns>
<SettingsEditing Mode="PopupEditForm" />
</dx:ASPxGridView>
</div>