Previous Thread:   Anyone using ASP.NET 2.0?

9/30/2005 12:58:55 PM    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...  
  
/************************OrderEdit.aspx) **********************/  
  
Page Load  
  
---------------  
  
linkAddContact.Attributes.Add("onclick","javascript:OpenPopup('ContactSelect.aspx')");  
  
RefreshOrderContacts()  
  
---------------------------  
  
public void RefreshOrderContacts()  
  
{  
  
OrderContactsData = SessionOrder.OrderContacts;  
  
if (dataGridOrderContact.Items.Count != OrderContactsData.Count)  
  
{  
  
dataGridOrderContact.DataSource = OrderContactsData ;  
  
dataGridOrderContact.DataBind();  
  
}  
  
}  
  
ContactSelect.aspx  
  
====================  
  
<input type="button"  
  
onclick="javascript:location.href='ContactEdit.aspx?Mode=Add'" value="  
  
Add New Contact  ">  
  
ContactEdit.aspx  
  
==================  
  
btn_Associate Click event  
  
-------------------------  
  
SessionOrder.OrderContacts.Add(SessionOrder.OrderID,  
  
SessionContact.ContactID);  
  
labelMessage.Text = "Contact successfully associated!!!";  
  
labelMessage.Visible = true;  
  
OrderEdit orderEdit = (OrderEdit) Session["OrderEdit"];  
  
orderEdit.RefreshOrderContacts();



9/30/2005 5:07:03 PM    Re: Datagrid not refreshing with new data
pv_kannan@yahoo.com wrote:  
  
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.IsPostBack)  
  
RefreshOrderContacts()  
  
else  
  
SaveContacts()  
  
RefreshOrderContacts()  
  
--  
  
Rob Schieber