473,624 Members | 2,252 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid not refreshing with new data

One of our dev team members is having a strange problem with a
datagrid...

We are not seeing a datagrid's data getting refreshed after a new row
is entered in a popup window inspite of resetting the datasource and
rebinding it.

We have a datagrid (enabled viewstate) that binds to a collection class
that inherits the IList interface. The datagrid displays list of
associated contacts for a customer order.

We have a linkbutton to add new contacts. Once this link is clicked, a
popup window shows up and all contacts for the customer are displayed.
The user has the option to add a new contact at this point. When they
do so, a dataentry form shows up in the popup. The user then enters the
details and chooses to Associate the new contact to the customer. The
expected behavior is that the new contact should show up in the
datagrid. But it does not.

We are calling the method that resets the datasource and binds the data
to the grid in the data entry screen. Stepping thru the ItemDataBound
event also shows the presence of the new row in the datasource. But the
datagrid is not refreshed.

Is there a way to do this?

I have posted relevant pieces of code...

/*************** *********OrderE dit.aspx) *************** *******/
Page Load
---------------
linkAddContact. Attributes.Add( "onclick","java script:OpenPopu p('ContactSelec t.aspx')");
RefreshOrderCon tacts()
---------------------------
public void RefreshOrderCon tacts()
{
OrderContactsDa ta = SessionOrder.Or derContacts;
if (dataGridOrderC ontact.Items.Co unt != OrderContactsDa ta.Count)
{
dataGridOrderCo ntact.DataSourc e = OrderContactsDa ta ;
dataGridOrderCo ntact.DataBind( );
}
}

ContactSelect.a spx
=============== =====
<input type="button"
onclick="javasc ript:location.h ref='ContactEdi t.aspx?Mode=Add '" value="
Add New Contact ">
ContactEdit.asp x
=============== ===

btn_Associate Click event
-------------------------

SessionOrder.Or derContacts.Add (SessionOrder.O rderID,
SessionContact. ContactID);

labelMessage.Te xt = "Contact successfully associated!!!";
labelMessage.Vi sible = true;

OrderEdit orderEdit = (OrderEdit) Session["OrderEdit"];
orderEdit.Refre shOrderContacts ();

Nov 19 '05 #1
1 1809
pv*******@yahoo .com wrote:
One of our dev team members is having a strange problem with a
datagrid...

We are not seeing a datagrid's data getting refreshed after a new row
is entered in a popup window inspite of resetting the datasource and
rebinding it.

We have a datagrid (enabled viewstate) that binds to a collection class
that inherits the IList interface. The datagrid displays list of
associated contacts for a customer order.

We have a linkbutton to add new contacts. Once this link is clicked, a
popup window shows up and all contacts for the customer are displayed.
The user has the option to add a new contact at this point. When they
do so, a dataentry form shows up in the popup. The user then enters the
details and chooses to Associate the new contact to the customer. The
expected behavior is that the new contact should show up in the
datagrid. But it does not.

We are calling the method that resets the datasource and binds the data
to the grid in the data entry screen. Stepping thru the ItemDataBound
event also shows the presence of the new row in the datasource. But the
datagrid is not refreshed.

Is there a way to do this?

I have posted relevant pieces of code...

/*************** *********OrderE dit.aspx) *************** *******/
Page Load
---------------
linkAddContact. Attributes.Add( "onclick","java script:OpenPopu p('ContactSelec t.aspx')");
RefreshOrderCon tacts()
---------------------------
public void RefreshOrderCon tacts()
{
OrderContactsDa ta = SessionOrder.Or derContacts;
if (dataGridOrderC ontact.Items.Co unt != OrderContactsDa ta.Count)
{
dataGridOrderCo ntact.DataSourc e = OrderContactsDa ta ;
dataGridOrderCo ntact.DataBind( );
}
}

ContactSelect.a spx
=============== =====
<input type="button"
onclick="javasc ript:location.h ref='ContactEdi t.aspx?Mode=Add '" value="
Add New Contact ">
ContactEdit.asp x
=============== ===

btn_Associate Click event
-------------------------

SessionOrder.Or derContacts.Add (SessionOrder.O rderID,
SessionContact. ContactID);

labelMessage.Te xt = "Contact successfully associated!!!";
labelMessage.Vi sible = true;

OrderEdit orderEdit = (OrderEdit) Session["OrderEdit"];
orderEdit.Refre shOrderContacts ();


Make sure to only bind if its not a postback, otherwise you'll lose your
data because it wont be in viewstate.

Example...

If(!Page.IsPost Back)
RefreshOrderCon tacts()
else
SaveContacts()
RefreshOrderCon tacts()

--
Rob Schieber
Nov 19 '05 #2

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

Similar topics

0
1264
by: serge calderara | last post by:
Dear all, I am develpping a .NET vb application fro 2000 and XP. I have actually an Collection list of Type, where type have 4 variables inside This collection list can be really long. I then pass the content of that collection list of type to a dat grid object which display them properly. The content of my collection list might change, it could be more records or
1
6272
by: James | last post by:
I have a data grid refresh problem. I have a few columns and the first column is data in the form of numbers. And in the form of the data grid if I specify for example something like a code(in a text box) the column of numbers should change colors depending on whether the number was in the specified code(if it belongs to the code, color the cell (first column) in Red and if not in some other color). It all works out fine until I scroll...
5
2581
by: Jeff | last post by:
IDE: VS 2003 :NET OS: XP Pro My app have a form with a tab-control on it. The tab-control have 2 tabpages. One of the tabpages displays a datagrid, and the other tabpage displays details (order date, name, address etc) about the selected row in the datagrid... My problem is when I enter a new record in the details tabpage (saves data to database), and go back to the datagrid. Only the data from the PM-table
3
15050
by: Brad | last post by:
I'm working with a DataGrid in C#, and the user needs to be able add and remove columns from the DataGrid on the fly, without opening and closing the form. The scenario is this. I have a setup table that allows users to rename columns, resize columns, and select whether or not they want them to be visible or not. While the user is working with a certain set of data, they will want to see certain columns, and in certain situations they...
1
1579
by: Hans | last post by:
I have a Windows.Forms.Form containing a DataGrid where the DataSource is a DataView. Everything refreshes fine after adding, deleting or editing rows. When I close the dialog and reopen it with a new set of data, all is okay showing the new rows of data. But when I go back to the first set of data, I get the correct data except for ONLY the second column of the first row contains the data from the second set of data. If I cause it to...
7
3548
by: A.M | last post by:
Hi, I want to refresh my DataGrid data on every postback. I have following code in Page_Load event, but after first page load, the DataGrid never gets refresh. Here is the code i have in Page_load (it works at first page_load): Dim DS As DataSet Dim MyConnection As System.Data.SqlClient.SqlConnection
1
3252
by: aliansari | last post by:
HI ... i am facing a problem while refreshing my datagrid ... i am developing a "Real time/Live data Stocks Trading Screen" ... what i want is to refresh my datagrid without refreshing the whole page ... there are couple of methods to do this which i know ... 1. Using Frames ... problem is gird will disappear and then redrawn on the page which i dont want. 2. Using XMLHTTP ... problem is i cant find any samples in .Net. so if any one of...
4
2123
by: Rod | last post by:
I posted a message to this group yesterday asking how to pass parameters to a web form that is the source of an IFrame on a parent web form. I've gotten my answer, and it works. Thanks! Now I have a different problem. The web form that is in the IFrame has a DataGrid in it. I have a button column in it which I use to trigger the deletion of the row in the database, and I want it to also reflect that deletion in the data grid. The...
6
5414
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).
17
2540
lee123
by: lee123 | last post by:
I know this is a free site and the moderators or anybody don't have to answer if they don't want to.. but if there is someone who knows how to answer this question please help with this one. i have changed my project so many times to try to get the results i want but can't seem to get this one thing to work the datagrid and datalist to work right. i have looked on the web to see if i could do it another way. and read so many books but there...
0
8242
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
8681
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8629
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8341
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
8488
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
7170
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
6112
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
4084
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
4183
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.