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
3 4335
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 -
-
drag a GridView
-
-
<asp:GridView ID="GridView1" runat="server">
-
</asp:GridView>
-
-
code behing page
declear namespace -
using System;
-
using System.Data;
-
using System.Data.SqlClient;
-
using System.Configuration;
-
using System.Collections;
-
using System.Globalization;
-
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;
-
-
-
public partial class Default2 : System.Web.UI.Page
-
{
-
SqlConnection myConnection;
-
-
protected void Page_Load(object sender, EventArgs e)
-
{
-
// Make a connection to the database
-
myConnection = new SqlConnection("server=servername; Initial Catalog=database name; User ID=username; password=password");
-
-
// get the data frm database when page load
-
if (!IsPostBack)
-
BindGrid();
-
-
}
-
-
public void BindGrid()
-
{
-
SqlDataAdapter myCommand1 = new SqlDataAdapter("select * from tablename ", myConnection);
-
-
-
DataSet ds = new DataSet();
-
myCommand.Fill(ds, "tablename");
-
-
GridView1.DataSource = ds.Tables["tablename"].DefaultView;
-
GridView1.DataBind();
-
myCommand.Connection.Close();
-
}
-
-
-
}
-
-
-
hope that gonna help you ...
But this code is Binding the GridView with PostBack, isn't it? Is there a way to bind using AJAX?
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 ?
|
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
|
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...
|
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...
|
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...
| |
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
|
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
|
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)
|
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...
|
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,...
|
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,...
| |
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| | |