473,662 Members | 2,724 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Asp.net, Webservice, Ajax, Fetching data dynamically..

dj12345
14 New Member
Hi,

I have 2 Gridviews on my asp.net page. In this gridview i am showing list of links. I want to update these links dynamically after 5-10 seconds, without refreshing the page(without postbak) i want to fetch these link dynamically and want to bind it to Gridview..

I have little bit idea about this that. use the webservice to fetch record like we do it in Ajax AutoComplete. But how to fetch record dynamically and bind it to Gridview..

Please can anybody tell me steps to do that..


Thanks

Yogesh Sapkale
May 15 '09 #1
3 4335
prabirchoudhury
162 New Member
ok fine.. i would just give an example of get data frm database and do databind . in C#

1. drag a GridView in the design page
2. declear the namespace in code behind page, call the Page_Load event

design page

Expand|Select|Wrap|Line Numbers
  1.  
  2. drag a GridView
  3.  
  4.  <asp:GridView ID="GridView1" runat="server">
  5.     </asp:GridView>
  6.  
  7.  
code behing page

declear namespace
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Data;
  3. using System.Data.SqlClient;
  4. using System.Configuration;
  5. using System.Collections;
  6. using System.Globalization;
  7. using System.Web;
  8. using System.Web.Security;
  9. using System.Web.UI;
  10. using System.Web.UI.WebControls;
  11. using System.Web.UI.WebControls.WebParts;
  12. using System.Web.UI.HtmlControls;
  13.  
  14.  
  15. public partial class Default2 : System.Web.UI.Page
  16. {
  17.     SqlConnection myConnection;
  18.  
  19.     protected void Page_Load(object sender, EventArgs e)
  20.     {
  21.         // Make a connection to the database
  22.         myConnection = new SqlConnection("server=servername; Initial Catalog=database name; User ID=username; password=password");
  23.  
  24.     // get the data frm database when page load
  25.         if (!IsPostBack)
  26.             BindGrid();
  27.  
  28.     }
  29.  
  30.     public void BindGrid()
  31.     {
  32.        SqlDataAdapter myCommand1 = new SqlDataAdapter("select * from tablename ", myConnection);
  33.  
  34.  
  35.         DataSet ds = new DataSet();
  36.        myCommand.Fill(ds, "tablename");
  37.  
  38.         GridView1.DataSource = ds.Tables["tablename"].DefaultView;
  39.         GridView1.DataBind();
  40.         myCommand.Connection.Close();
  41.     }
  42.  
  43.  
  44. }
  45.  
  46.  
  47.  
hope that gonna help you ...
May 15 '09 #2
AnaOlinto
4 New Member
But this code is Binding the GridView with PostBack, isn't it? Is there a way to bind using AJAX?
Aug 14 '09 #3
Frinavale
9,735 Recognized Expert Moderator Expert
When you use Ajax in .NET the whole page ASP page life cycle happens.

This means that if you place your GridView in an update panel and then use a Ajax Timer control to periodically cause an asynchronous post back to the page then everything server side is executed.

When the postback is sent down to the browser, the HTML is stripped down by .NET to only include what needs to be updated (which is within the UpdatePanel).

In my mind, it's sort of a .NET cheat. If you use pure Ajax, this is much different.

Anyways, just try adding an UpdatePanel to the page, and place the GridView in the UpdatePanel. Place a Timer control in the UpdatePanel and have it periodically cause an asynchronous postback to the server so that the GridView is refreshed (not the whole page).

-Frinny
Aug 17 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1427
by: Ulf | last post by:
I have found Ajax and webservice.htc that is not supported any more. Is there a built in funcion for webservices in Visual Studion 2005 / .Net 2.0 ? What is the best solution ?
7
3545
by: sameer | last post by:
Hi all, Application environment : VB.Net desktop application,.NET 1.1 Framework, VS 2003. communicates between the database and the application is done over webservices using ADO.NEt Datasets. Returned dataset is Gzip compressed and is then decompressed on the receiving side. Every thing works good, the problem is that it takes a lot of time for the
1
3462
by: peter.konda | last post by:
Hello! I have been busting my head with a problem, that goes like this: 1. with a first ajax call to the server(apache 2.0 + php), I create a temporary table like this: create temporary table peter select * from some_table limit 0,0; That creates an empty temporary table with the same structure as some_table. I use mysql 4.023. I use php call mysql_connect to connect to the mysql database. 2. I create a second ajax call to the server...
0
1270
by: krishnangopi | last post by:
i have developed a webservice in Asp.Net(using Vb.Net).to test the webservice a sample GUI windows application was developed.i will be fetching data from server to client in the form of XML String throught webservice the downloaded data will be inserted into client database the problem is that while downloading data from server if there is abreak in net connection the entire process has to be rollbacked but now rollback is not happening...
2
3291
by: Jay | last post by:
Getting into AJAX using the XMLHttp object and am really liking it. We are in the process of upgrading our existing behavior calls (webservice.htc) to the more 'supported', as they say, concept of AJAX. One thing I noticed was that the .htc code practically does the same thing AJAX does - with nice code that allows you to .value reference the return XML nice and easily - and now I'm wondering why I should even bother trying to reinvent...
1
2977
by: hesameagle | last post by:
Hi I want to use ajax to connect to database and echo some data in my page, I wrote these two codes that can handle my need: index.php ----------------------------------------- <?php //This file is text.php
2
686
by: =?Utf-8?B?TW9oc2luIEtoYW4=?= | last post by:
Hi, I am working on a website where i am creating Horizontal Menus Dynamically from database as per rights available to the user. I have several UserControls. And the Menu control also brings UserControl's URL stored in Database while Page load. There is a TabContainer control below the Menu Control. Now i want to add corresponding UserControl dynamically when user clicks on
7
6651
by: RichB | last post by:
I am trying to get to grips with the asp.net ajaxcontrol toolkit, and am trying to add a tabbed control to the page. I have no problems within the aspx file, and can dynamically manipulate a tabcontainer which has 1 panel already, however I want to try create the TabPanels dynamically. I followed the advice here: http://www.asp.net/learn/ajax-videos/video-156.aspx (3rd comment - Joe Stagner)
1
1637
oranoos3000
by: oranoos3000 | last post by:
hi i have a script that with click a button in this script text with id="targetDiv" is substitute with content of the file data.txt. this script and data.txt are on the same directory on my local disk my problem is that with pressing button on this script this is not substituted and XMLHttpRequestObject.status instead of 200 is 0 what is meaning of XMLHttpRequestObject.status instead equal to zero? how can i change...
0
8345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8547
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7368
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4181
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4348
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1999
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1754
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.