473,671 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to refresh a DataGrid?

Hi,

This might be the easiest question ever but I can't seem to find how to do
it: I have a DataGrid that's linked to an instance of IList (actually, it's
an ArrayList). On load, there's already data in the collection so when I
call the DataGrid's 'SetDataBinding ' method, the DataGrid displays the data
correctly.

Problem is that when I add data to the collection afterwards, I can't
display it in the DataGrid. I tried calling its 'Refresh' method, its
'Update' method and even the 'SetDataBinding ' method again without success.

Basically, in this case, how can I refresh the data in a DataGrid once the
source has changed?

Thanks,

SC
Nov 16 '05 #1
1 1859
SC,

You could set the DataSource of the grid to null, and then back to the
list. This is the hacky way.

If you wanted the grid to update when changes are made, then implement
the IBindingList interface, which has an event that you fire when changes
are made to your list.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Skip" <Sk**@discussio ns.microsoft.co m> wrote in message
news:9F******** *************** ***********@mic rosoft.com...
Hi,

This might be the easiest question ever but I can't seem to find how to do
it: I have a DataGrid that's linked to an instance of IList (actually,
it's
an ArrayList). On load, there's already data in the collection so when I
call the DataGrid's 'SetDataBinding ' method, the DataGrid displays the
data
correctly.

Problem is that when I add data to the collection afterwards, I can't
display it in the DataGrid. I tried calling its 'Refresh' method, its
'Update' method and even the 'SetDataBinding ' method again without
success.

Basically, in this case, how can I refresh the data in a DataGrid once the
source has changed?

Thanks,

SC

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1577
by: msnews | last post by:
Hi -- I'm very, very new to ASP.Net, and I've been trying for several days to figure out how to update a datagrid AND refresh it on the client side so that the page doesn't refresh. I've torn my code apart over and over each time I tried what I thought would be the code that would solve my problem. Maybe I'm going down the completely wrong path here. Essentially, here is an explanation of my ASP.NET webform application and what I want...
4
5033
by: Cat | last post by:
If you have a datagrid with an underlying dataset and rows are added to the dataset during a program run, how do you get the datagrid to update itself to repflect the changes in the underlying dataset? I've tried Update() and Refresh() but these don't seem to work. Only thing that works is rebinding the datset to the datagrid control, but this doesn't seem to be quite right. Cat
0
4225
by: lucas | last post by:
Hi, I have a simple input form that i use to add records to a sql server database. Bellow that is a datagrid that has one template column that I use to dispaly the 3 fields with some html formating. the datagrid also has paging. I'm doing a ASP.NET guestbook. I know some things could be improved like adding some error handling and caching the dataset instead of querying the database on every page load....but I'm still working on the...
0
1980
by: Marcus | last post by:
Hello! I'm buildning a webpage in ASP.NET using Visual Basic. The page contains a datagrid, a dropdownlist, some textboxes and a couple of buttons. The datagrid displays barcodes from a table in a database (Sql Server 2000). I want to automatic update the datagrid when new new posts arrives in the table. Before the datagird is updated, the choosen index from the
1
1916
by: Andre | last post by:
hi, In my Datagrid i have some text and a image (for each item), if i edit the image and save it to the HD there's no problem, but the image is always saved with the same name (item number.jpg) so after the change the datagrid does'nt refresh the image because her name did not change. My question is : Is there a way to "refresh" the datagrid after the edit function, to refresh the image ?
7
15438
by: Juan Romero | last post by:
Hey guys, please HELP I am going nuts with the datagrid control. I cannot get the damn control to refresh. I am using soap to get information from a web service. I have an XML writer output the file to a folder, and then I read it back into the dataset using the dataset1.readxml. Up to this point, everything works wonderfully. The query executes, the dataset gets populated, and I get the results displayed in the datagrid.
0
1307
by: Erik | last post by:
I have a Form that has 2 OleDbAdapters and one dataset object. In the dataset I have two tables that are joined. My datagrid is looking at one table. I add new records to the datagrid. I want to be able to reload the datagrid or refresh the contents of the datagrid. Problem is that when I refresh the dataset it also refreshes the other table. How can I reload...refresh the datagrid without using the dataset object.
2
4561
by: Dan | last post by:
Hi, I have a Datagrid in a simple form that I programmatically modify using something like that : Me.DataGrid1(RowID, ColID) = "blablabla" But my cell wont refresh unless I click on another cell or move the scrollbar of the datagrid... :(
3
7543
by: David Cartwright | last post by:
Hi all, I'm having a weird time with a call to the Refresh() method of a DataGridView. I have a VB.NET 2005 Windows application with a main form and a "worker" thread. The main form delegates a Sub to the worker so that the latter can refresh the DataGrid after updating the DataTable driving it. When I run the app under the debugger, everything's fine. But when I run it for real, it hangs, apparently in the Refresh() method of the...
6
5415
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi - I'm having trouble refreshing a datagrid control bound to a dataset that was created from the New Data Source wizard. What is the code required to refresh the datagrid with data from the data source (sql db)? More Details: The application is C# Windows (VS 2005).
0
8483
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8402
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,...
0
8676
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
7445
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...
0
5703
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
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...
1
2819
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2062
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1816
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.