This question is locked. New answers and comments are not allowed.
Hello,
I am setting up a grid for incoming data that is categorical. I do not know how many categories said data will have so it is dynamic. So I have set up something like this:
The problem is, this repeats the first data for each column. So I have tried something like this:
But this return blank.
I have also tried:
Which seems to have worked for Header but that too returned blank.
So how can I get the index of PercentageColumn, i.e: PercentageColumn[0] for first column and PercentageColumn[1] for second column etc so it binds to new data.
I am not even sure if I am going about the right way of handling dynamic columns but it made sense to me and I feel I am just missing the right syntax?
Thanks for any help/ideas!
I am setting up a grid for incoming data that is categorical. I do not know how many categories said data will have so it is dynamic. So I have set up something like this:
//if column got sent, put them in the grid alongside visit Debug.Assert(Phpdata != null, "Phpdata != null"); if (Phpdata.ColumnCount != 0) { //populate grid for categorical data Debug.Assert(Phpdata.Visit != null, "Phpdata.Visit != null"); for (var i = 0; i < Phpdata.Visit.GetLength(0); i++) { var ds = new Datas { VisitColumn = Phpdata.Visit[i], nColumn = Phpdata.n[i], PercentageColumn = Phpdata.Percentage[i] }; MyData.Add(ds); } //for each column create column n and column percentage Debug.Assert(Phpdata != null, "Phpdata != null"); for (var c = 0; c < Phpdata.ColumnCount; c++) { var totalcolumn = new GridViewDataColumn { DataMemberBinding = new Binding("nColumn"), Header = Phpdata.ColumnName[c] + " [n]", UniqueName = "TotalColumn" + c }; var percentageColumn = new GridViewDataColumn { DataMemberBinding = new Binding("PercentageColumn"), Header = Phpdata.ColumnName[c] + " [%]", UniqueName = "PercentColumn" + c }; RadGrid.Columns.Add(totalcolumn); RadGrid.Columns.Add(percentageColumn); }The problem is, this repeats the first data for each column. So I have tried something like this:
//same part as above just with binding changed
var percentageColumn = new GridViewDataColumn { DataMemberBinding = new Binding("PercentageColumn[" + c + "]"), Header = Phpdata.ColumnName[c] + " [%]", UniqueName = "PercentColumn" + c };But this return blank.
I have also tried:
DataMemberBinding = new Binding("Phpdata.Percentage[" + c + "]")So how can I get the index of PercentageColumn, i.e: PercentageColumn[0] for first column and PercentageColumn[1] for second column etc so it binds to new data.
I am not even sure if I am going about the right way of handling dynamic columns but it made sense to me and I feel I am just missing the right syntax?
Thanks for any help/ideas!