Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Datagrid not refreshing with new data

Reply
Thread Tools

Datagrid not refreshing with new data

 
 
pv_kannan@yahoo.com
Guest
Posts: n/a
 
      09-30-2005
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","javascrip t: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.asp x?Mode=Add'" value="
Add New Contact ">


ContactEdit.aspx
==================

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

SessionOrder.OrderContacts.Add(SessionOrder.OrderI D,
SessionContact.ContactID);

labelMessage.Text = "Contact successfully associated!!!";
labelMessage.Visible = true;

OrderEdit orderEdit = (OrderEdit) Session["OrderEdit"];
orderEdit.RefreshOrderContacts();

 
Reply With Quote
 
 
 
 
Rob Schieber
Guest
Posts: n/a
 
      09-30-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) 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...
>
> /************************OrderEdit.aspx) **********************/
> Page Load
> ---------------
> linkAddContact.Attributes.Add("onclick","javascrip t: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.asp x?Mode=Add'" value="
> Add New Contact ">
>
>
> ContactEdit.aspx
> ==================
>
> btn_Associate Click event
> -------------------------
>
> SessionOrder.OrderContacts.Add(SessionOrder.OrderI D,
> 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()

--
Rob Schieber
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Self-refreshing and non-self-refreshing controls Harlan Messinger ASP .Net 1 08-04-2006 01:13 PM
Self-refreshing and non-self-refreshing controls Harlan Messinger ASP .Net Web Controls 0 08-03-2006 12:29 PM
Image in datagrid not refreshing kaczmar2@hotmail.com ASP .Net 1 07-28-2005 07:54 PM
Postback problem - datagrid not refreshing b_naick@yahoo.ca ASP .Net 0 01-20-2005 07:05 PM
Datagrid is not refreshing after postback Kreebog ASP .Net Datagrid Control 2 02-26-2004 07:03 PM



Advertisments