Note that there are some explanatory texts on larger screens.

plurals
  1. POupdate datagridview using ajax in my asp.net without refreshing the page.(Display real time data)
    text
    copied!<p>I need to display a real time data from MS SQL 2005. I saw some blogs that recommend Ajax to solve my problem. Basically, right now I have my default.aspx page only just for a workaround I could able to display the data from my DB. But once I add data manually to my DB there's no updating made. Any suggestions guys to fix this problem? I need to update datagridview with out refreshing the page.</p> <p>Here's my code on Default.aspx.cs</p> <pre><code>using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { FillDataGridView(); } protected void up1_Load(object sender, EventArgs e) { FillDataGridView(); } protected void FillDataGridView() { DataSet objDs = new DataSet(); SqlConnection myConnection = new SqlConnection (ConfigurationManager.ConnectionStrings["MainConnStr"].ConnectionString); SqlDataAdapter myCommand; string select = "SELECT * FROM Categories"; myCommand = new SqlDataAdapter(select, myConnection); myCommand.SelectCommand.CommandType = CommandType.Text; myConnection.Open(); myCommand.Fill(objDs); GridView1.DataSource = objDs; GridView1.DataBind(); } } </code></pre> <p>Code on my Default.aspx</p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml" &gt; &lt;head runat="server"&gt; &lt;title&gt;Ajax Sample&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"&gt; &lt;Scripts&gt; &lt;asp:ScriptReference Path="JScript.js" /&gt; &lt;/Scripts&gt; &lt;/asp:ScriptManager&gt; &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server" OnLoad="up1_Load"&gt; &lt;ContentTemplate&gt; &lt;asp:GridView ID="GridView1" runat="server" Height="136px" Width="325px"/&gt; &lt;/ContentTemplate&gt; &lt;Triggers&gt; &lt;asp:AsyncPostBackTrigger ControlID="GridView1" /&gt; &lt;/Triggers&gt; &lt;/asp:UpdatePanel&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>My problem now is how to call or use the ajax.js and how to write a code to call the FillDataGridView() in my Default.aspx.cs page.</p> <p>Thank you guys, hope anyone can help me on this problem. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload