Datagrid not refreshing with new data

P

pv_kannan

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();
 
R

Rob Schieber

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();

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()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top