Walaa,
Thanks for the response. However I think the approach you suggested will not work in my case because I use the later DataSourceId property of the gridview instead of the older DataSource and DataBind code behind approach.
Below are my findings and my questions:
IN ASCX FILE
<llblgenpro:LLBLGenProDataSource2 ID="ldsNdcLabelname" runat="server" AdapterTypeName="MW.DAL.DatabaseSpecific.DataAccessAdapter, MW.DALDBSpecific" CacheLocation="Session" DataContainerType="TypedList"
LivePersistence="False" OnPerformSelect="ldsNdcLabelname_PerformSelect" >
</llblgenpro:LLBLGenProDataSource2>
...
<asp:GridView ID="gvNdcLabelname" runat="server" AllowPaging="True" AutoGenerateColumns="False"
DataKeyNames="LabelName" DataSourceID="ldsNdcLabelname" OnPageIndexChanged="gvNdcLabelname_PageIndexChanged"
OnSelectedIndexChanging="gvNdcLabelname_SelectedIndexChanging" Visible="true" OnPageIndexChanging="gvNdcLabelname_PageIndexChanging"
BorderColor="Silver" >
...
IN CS FILE
...
private NdcDistinctLabelnameTypedList _ndcTypedList;
...
public void DisplayLabelnamesSearched(NdcDistinctLabelnameTypedList ndcs)
{
_ndcTypedList = ndcs;
gvNdcLabelname.DataBind();
}
...
protected void ldsNdcLabelname_PerformSelect(object sender, PerformSelectEventArgs2 e)
{
ldsNdcLabelname.TypedList = _ndcTypedList;
}
With the above code behind .cs file, the gridview never shows the fetched typedlist.
IN CS FILE
...
private NdcDistinctLabelnameTypedList _ndcTypedList;
...
public void DisplayLabelnamesSearched(NdcDistinctLabelnameTypedList ndcs)
{
_ndcTypedList = ndcs;
ldsNdcLabelname_PerformSelect();
}
...
protected void ldsNdcLabelname_PerformSelect(object sender, PerformSelectEventArgs2 e)
{
ldsNdcLabelname.TypedList = _ndcTypedList;
}
With the above code behind the ldsNdcLabelname_PerformSelect() got invoked twice after it is called by DisplayLabelnamesSearched routine the first time the DisplayLabelnamesSearched is called. By the way, DisplayLabelnamesSearched() is invoked by a button click event.
So basically here's what happended:
formload
button click
DisplayLabelnamesSearched()
ldsNdcLabelname_PerformSelect()
ldsNdcLabelname_PerformSelect()
...
a second button click
DisplayLabelnamesSearched()
ldsNdcLabelname_PerformSelect()
QUESTIONS:
Does any one know why the ldsNdcLabelname_PerformSelect() got invoked 2x?
Further more, the in the second time that ldsNdcLabelname_PerformSelect() got invoked (first button click), the ldsNdcLabelname.TypedList.Count went back to zero. I wonder why?
Basically what happened is that when a function invoked the PerformSelect() routine manually, it is being invoked twice (must be due to some sort of behind the scene binding with the gridview) and the second time around the ldsNdcLabelname.TypedList was reset so the count is zero. Why?