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
Hello Sneha,
Thank you for getting back to me.
I will close this case now. Please keep in mind that closed cases could be reopened with 30 days of closure.
Thank you for using Infragistics.
Regards, Monika Kirkova, Infragistics
Hello Monika,
Being in short of time, we are proceeding with another alternative approach unrelated to this. Thank you for your quick responses.
In the provided sample, new columns are added and display as expected. This means that the approach is correct and we need to identify what might be causing the issue on your side. As a first step, can you please let me know how my sample behaves on your side?
If it is working as expected this means that everything in the environment is fine and there is something in the setup of your application that is causing the issue. In order to determine what it might be you can start modifying my sample, adding one feature at a time, in order to replicate the behavior and send it back to me for further investigation. Having a working sample on my side, which I can debug, is going to be very helpful in finding the root cause of this behavior.
Thank you for your cooperation.
Looking forward to hearing from you.
Regards,
Monika Kirkova,
Infragistics
I have done same thing, but still i'm not able to see the new column.
After investigating this further, I determined that the controls from the user control could be added to a placeholder. The webGridResults variable would be defined and the webDataHierarchicalGrid saved as follows:
var webGridResults = new WebHierarchicalDataGrid();
for (int i = 0; i < p.Controls.Count; i++)
{
if (p.Controls[i] != null)
webGridResults = this.p.Controls[i].FindControl("whdg") as WebHierarchicalDataGrid;
if (webGridResults != null)
webGridResults.EnableDataViewState = true;
webGridResults.Columns.Add(boundField);
Where p is the id of the placeholder. A breakpoint could be added to the following line in order to display information regarding the columns: Console.Write(webGridResults.Columns);
Below I am attaching a sample for your reference. Please test it on your side and let me know how it behaves. If this is not an accurate demonstration of what you are trying to achieve please feel free to modify it and send it back to me along with steps to reproduce.
WebHierarchicalDataGrid.rar