Hello togheter,
could somebody please support me by the following data binding issue:
On my web site I have two buttons (A & B).
When I click button A, I would like to bind data source A with the dedicated columns to the WebHierarchicalDataGrid.
When I click button B, I would like to bind data source B with the dedicated columns to the WebHierarchicalDataGrid.
HTML:
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<ig:WebHierarchicalDataGrid ID="WebHierarchicalDataGrid1" runat="server" Height="500px" Width="400px">
<GroupingSettings EnableColumnGrouping="True" GroupAreaVisibility="Visible" GroupByAreaLocation="Top"/>
<Behaviors>
<ig:Activation Enabled="true"></ig:Activation>
<ig:Selection Enabled="true" RowSelectType="Single" CellClickAction="Row" ></ig:Selection>
<ig:RowSelectors Enabled="true" RowNumbering="true" EnableInheritance="true"></ig:RowSelectors>
<ig:Paging Enabled="true" EnableInheritance="true" PagerMode="Numeric" PageSize="100"></ig:Paging>
<ig:Sorting Enabled="true" EnableInheritance="true" SortingMode="Single"></ig:Sorting>
</Behaviors>
</ig:WebHierarchicalDataGrid>
<asp:Button ID="Button_A" runat="server" Text="Button_A" OnClick="Button_A_Click" />
<asp:Button ID="Button_B" runat="server" Text="Button_B" OnClick="Button_B_Click" />
</div>
</form>
</body>
Page_Load:
if(!Page.IsPostBack)
{
Session["DataSource_Session"] = null;
WebHierarchicalDataGrid1.AutoGenerateColumns = false;
}
object data = Session["DataSource_Session"];
if(data != null)
if (data.GetType() == typeof(A[]))
WebHierarchicalDataGrid1.DataKeyFields = WebHierarchicalDataGrid1.Columns[0].Key;
WebHierarchicalDataGrid1.DataSource = (A[])data;
WebHierarchicalDataGrid1.DataBind();
else if (data.GetType() == typeof(B[]))
WebHierarchicalDataGrid1.DataSource = (B[])data;
Button_Click_Event:
protected void Button_B_Click(object sender, EventArgs e)
try
WebHierarchicalDataGrid1.Columns.Clear();
WebHierarchicalDataGrid1.GridView.ClearDataSource();
BoundDataField dtf = new BoundDataField();
dtf.Header.Text = "Unique ID";
dtf.Key = "uniqueID";
dtf.DataFieldName = "uniqueID";
BoundDataField dtf1 = new BoundDataField();
dtf1.Header.Text = "Value B";
dtf1.Key = "valueB";
dtf1.DataFieldName = "valueB";
WebHierarchicalDataGrid1.Columns.Add(dtf);
WebHierarchicalDataGrid1.Columns.Add(dtf1);
B[] valueList = new B[10];
for (int i = 0; i < 10; i++)
B obj = new B();
obj.uniqueID = i;
obj.valueB = "Value B " + i.ToString();
valueList[i] = obj;
WebHierarchicalDataGrid1.DataKeyFields = WebHierarchicalDataGrid1.Columns[0].Key WebHierarchicalDataGrid1.DataSource = valueList;
WebHierarchicalDataGrid1.GridView.DataKeyFields = WebHierarchicalDataGrid1.DataKeyFields;
WebHierarchicalDataGrid1.GridView.DataSource = WebHierarchicalDataGrid1.DataSource;
WebHierarchicalDataGrid1.GridView.DataBind();
WebHierarchicalDataGrid1.RefreshBehaviors();
Session["DataSource_Session"] = valueList;
catch (Exception ex)
string msg = ex.Message;
protected void Button_A_Click(object sender, EventArgs e)
dtf1.Header.Text = "Value A";
dtf1.Key = "valueA";
dtf1.DataFieldName = "valueA";
A[] valueList = new A[10];
A obj = new A();
obj.valueA = "Value A " + i.ToString();
Data_Source_Class:
public class A
Int64 _uniqueID;
public Int64 uniqueID
get { return _uniqueID; }
set { _uniqueID = value; }
string _valueA;
public string valueA
get { return _valueA; }
set { _valueA = value; }
public class B
string _valueB;
public string valueB
get { return _valueB; }
set { _valueB = value; }
Thanks in advanced.
Hello help123,
Thank you for the provided video.
Since I am not able to reproduce this behavior on my side could you please modify the sample project that I provided in my last post in order to reproduce the issue.
This will help me debug on my side and investigate further in pursuit of the root cause of the issue.
Thank you for your cooperation on this matter.
Looking forward to hearing from you
Hi, please see attachment. The issue occurs on IE 11 as well as on Firefox. BR
I tested he provided sample and following the steps that you suggested I was unable to reproduce the issue with the hidden columns that you are describing. I added one hidden column in the grid and regardless of how many browser tabs I have opened with the application hidden columns remained hidden.
Regarding the first issue I assume that the function that you are mentioning is the function that changes the data source for the grid. On my side this was working as expected as well and the underlying data source of the grid was flawlessly changed upon a button click.
I modified the sample that I have provided to you in order to add an additional hidden column in the grid and I am attaching it for your reference. Please test this on your side and let me know whether you are experiencing mentioned issues with the sample. If not, please feel free to modify my sample and send it back to me.
If you are having the same issue with my sample as well could you please make a video illustrating the behavior on your side and provide me with steps to reproduce the issue and some additional information regarding the browser and browser version.
Looking forward to hearing from you.
Hi, I have another 2 side effects which I could not solve:
- When I open the page in two browser tabs the function is not working properly
- In my main project some columns are hidden. When I open the page in two browser tabs in one all columns are displayed. I figured out that the <head> with ‘runat=server’ has some impact. But I could not finally solve the problem. What could be the reason?
Thanks in advanced!
Hello,
I am glad that you have been able to achieve your requirement.
Please let me know if you have any additional questions regarding this matter.