We have a FileExplorer in our application which is built dynamicallly. On click of a tree node, we are trying to rebind the grid with the value of the node clicked. The datasource of the grid has the updated data but after the code passes rebind statement, the grid still holds the old value. Below is our PopulateGrid() method and it is invoked in OnPreRender.
public void PopulateGrid()
{
try
{
DataTable dtDocList = new DataTable();
dtDocList = createDataTable(dtDocList);
DataRow docListRow = null;
if (FileExplorerDataSource.Count > 0)
{
foreach (DMSDocument currentDoc in FileExplorerDataSource)
{
docListRow = dtDocList.NewRow();
foreach (AspenDocumentListWebControlShowColumnsConfigurationElement column in AspenDocumentListUIConfig.ColumnsToShow)
{
foreach (DMSMetadata currProperty in currentDoc.Properties)
{
if (currProperty.Name == column.DataField)
{
docListRow[column.Name] = currProperty.Value;
break;
}
}
}
if (String.IsNullOrEmpty(filterExpression))
{
dtDocList.Rows.Add(docListRow);
}
else if (docListRow["DocumentType"].ToString() == filterExpression.ToString())
{
dtDocList.Rows.Add(docListRow);
}
}
if (String.IsNullOrEmpty(filterExpression))
{
Documents = dtDocList;
DataView sortedDocListView = new DataView(dtDocList);
if (dtDocList != null)
{
sortedDocListView.Sort = dtDocList.Columns["CreationDate"] + " DESC";
}
docListGrid.DataSource = sortedDocListView;
docListGrid.DataBind();
}
else
{
DataView sortedDocListView2 = new DataView(dtDocList);
if (dtDocList != null)
{
sortedDocListView2.Sort = dtDocList.Columns["CreationDate"] + " DESC";
}
//docListGrid.SortExpressions.Clear();
docListGrid.DataSource = sortedDocListView2;
docListGrid.Rebind();
}
}
else
{
//docListGrid.MasterTableView.NoRecordsTemplate = new NoRecordsTemplate();
}
}
catch (Exception)
{
// LogError(ex.Message + " /n Stack Trace :" + ex.StackTrace);
}
}
The filter expression will have the value of the tree node clicked.
This is quite urgent. Any help is very much appriciated.
Thanks in advance.
Regards
Rajeev