Click here to Skip to main content
14,691,952 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I calling the Method using code behind and Postback . writing Ado.net with textbox click search for Id it give me back the data based on ID .

I want to load or do the same Work but with AJAX and get xml back

please look at me code :

What I have tried:

On System.Web.UI.Page

public void GetArtikelByNavisionID()
      {
          string 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 :
<script type="text/javascript">

</script>

    <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>
Posted
Updated 5-Dec-19 3:34am
Comments
vinay.tatipamula 5-Dec-19 4:59am
   
You need to make that method as webmethod. Follow https://stackoverflow.com/questions/4313532/pagemethods-in-asp-net

1 solution

You can use ScriptManager and UpdatePanel.
Check this link Introduction to the UpdatePanel Control | Microsoft Docs[^]
This is more like using grid in UpdatePanel, Gridview with updatepanel in Asp.net C# • ParallelCodes[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900