Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
15
Dynamically adding BoundField to WebHierarchialDataGrid, unable to see the column in browser
posted

I have a WebHierarchialDataGrid 'G1' in usercontrol page .ascx page with 20 columns existing. I'm getting data from .ascx page to .aspx page in ON_INIT() method adding controls to div 'Results'. After adding the controls, Through FindControls method I'm assigning the WebHierarchialDataGrid 'G1' to variable webGridResults and added a new Boundfield field column to it.


this.TDSearchResults.Controls.Add(this.SearchResults);
if (!Page.IsPostBack)
{
BoundDataField boundField = new BoundDataField();

boundField.Header.Text = "CERT_ALLOWED";

boundField.Key = "CERT_ALLOWED";

boundField.DataFieldName = "CERT_ALLOWED";

boundField.Hidden = false;

//boundField.Header.CssClass = "aLeft";

boundField.Width = Unit.Pixel(20);
try
{
for (int i = 0; i<TDSearchResults.Controls.Count; i++)
{
if (TDSearchResults.Controls[i] != null)
{
this.webGridResults = this.TDSearchResults.Controls[i].FindControl("G1") as WebHierarchicalDataGrid;
}
if (webGridResults != null)
{
webGridResults.EnableDataViewState = true;
webGridResults.Columns.Add(boundField);
}
}
}
catch
{

}

I have checked in Page_Load, Pre_Render, On_Load events I able to see the new Column, but in the browser I'm unable to see the column, On Inspect_Element I'm able to see new column in only script webhierarchialdatagrid_addinit. 

How to view the column in browser? How to check if data is getting binded or not(providing the data to grid datasource)? Please let me know. 

Thanks,

Sneha

Parents Reply Children
No Data