Gridview not refreshing!

J

joechipubik

I have a GridView in a FormView that has as its datasource a DataTable
that is stored in the session cache.
When I first load the page the GridView is displayed correctly, but on
subsequent loads the GridView does not display. I've debugged the
DataTable and even when it has data and is bound to the GridView, when
the page loads the GridView is not displayed. I set the datasource and
then bind the GridView. I've tried disabling the ViewState for the
GridView but to no avail.
I'm at a loss to understand why the GridView is not displaying! I
suspect its due to the FormView but can't prove anything yet. Any
ideas?
Thanks for reading.
 
J

joechipubik

To give you some more details - the user clicks on a row in a gridview
called GrdVwLabelsSearchResults and then the method
DisplayLabelDetails() is called, which calls
BindSignatoryAndCCGridViews() to update the gridview GrdVwLabelContacts
on the FormView.
The datasource for GrdVwLabelContacts is a DataTable which is kept in
the Session Cache because rows can be added and removed from this
GridView.

protected new void Page_Load(object sender, EventArgs e)
{
//To trap a click event on the GrdVwLabelsSearchResults
gridview
string controlName = Request.Params.Get("__EVENTTARGET");
string passedArgument =
Request.Params.Get("__EVENTARGUMENT");

//check to see if the passedArgument was from the
GrdVwUsersSearchResults
//Get the labelID of the selected row and then
//display label details
if (controlName == "GrdVwLabelsSearchResults" &&
passedArgument.StartsWith("RowClicked"))
{
string labelID = passedArgument.Substring(10);
DisplayLabelDetails(labelID);
}

}

protected void DisplayLabelDetails(string labelid)
{
//change FormView to Edit Mode
FrmVwLabel.ChangeMode(FormViewMode.Edit);

//bind the Label Signatory and Contact Gridviews
BindSignatoryAndCCGridViews(labelid);
PnlLabelDetails.Visible = true;
FrmVwLabel.Visible = true;
}

protected void BindSignatoryAndCCGridViews(string labelStr)
{

DataTable labelCCDT = new DataTable();
if (CacheSession.GetLabelCCDT() == null)
{
labelCCDT = LabelManager.GetContactsForLabel(labelId,
contactRoleId);
CacheSession.SetLabelCCDT(labelCCDT);
}
else
{
labelCCDT = CacheSession.GetLabelCCDT();
}
GridView grdVwLabelCC =
(GridView)FrmVwLabel.FindControl("GrdVwLabelContacts");
grdVwLabelCC.DataSource = labelCCDT;
grdVwLabelCC.DataBind(); //<----- this is not updating the GridView
correctly
grdVwLabelCC.Visible = true;
}
 

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

Top