Hello,
I need to access the data in a hidden column in the RowDataBound event. I am using the following on page load complete to hide the Column:
GridGroupingControl1.TableDescriptor.VisibleColumns.Remove("MATERIAL_ID")
I was using the code below to get the column ID, but it stopped working once the column was hidden:
GridGroupingControl1.TableDescriptor.Columns.GetColumnDescriptor("MATERIAL_ID").GetRelativeColumnIndex()
So now I am getting the hidden column index through different means (it happens to be column 15 in this example).
I am using the following line to get the cell text:
e.Row.Cells(15).Text
This works well for visible columns, but fails on the hidden column.
My goal is to use a hidden column to store row specific data. I need to both populate it, and use it's values in the RowDataBound event but need it to remain hidden at all times. I don't want to use JavaScript, or any hacks to make this work. I am actually somewhat surprised that there isn't a property like 'Hidden='True'' for GridGroupingControl columns.
Visual Studio 2010
.NET Framework 4.0
Essential Studio 10.4.0.71
VB.Net Code behind
Thanks!
--Dale
Hi Dale,
Thank you for your interest in Syncfusion products.
Query : Hidden columns value in RowDataBound event.
We would like to let you know that when a column is removed from VisibleColumns collection you cannot retrieve the hidden column text value using e.Row.Cells[index].Text. It only contains the cell values of visible columns. We suggest you to use e.Row.Record.GetValue("ColumnName") to retrieve the value of hidden column and use it as per your requirement in RowDataBound event. Please refer below code snippet for further details.
[ aspx.cs ]
void GridGroupingControl1_RowDataBound(object sender, Syncfusion.Web.UI.WebControls.Grid.Grouping.RowDataBoundEventArgs e)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
if (((GridCell)(e.Row.Cells[i])).ColumnDescriptor != null)
{
//Check if the name of the column
if (((GridCell)(e.Row.Cells[i])).ColumnDescriptor.Name == "City")
{
//EmployeeID is a Hidden Column
if ((int)e.Row.Record.GetValue("EmployeeID") % 2 == 0)
e.Row.Cells[i].BackColor = System.Drawing.Color.Red;
}
}
}}
For your convenience we have prepared a sample for the above scenario and it is attached below. Please refer to it.
Sample :
Please let us know if you have any concerns.
Regards,
Rakesh D
Thank you! That did work. Are there any other limitations with hidden columns? Do you know of any other methods that might could be used for both hidden and visible columns?
Thanks!
--Dale
Hi Dale,
Thank you for your interest in Syncfusion products.
Query : Any other methods that might could be used for both hidden and visible columns?
In order to use same method for both hidden and visible column we suggest you to hide the required column from grid by using “HideColumn” method in client side. Please refer below code snippet for further details.
function PageLoad() {
var gridTable = GetEGridTable($get('<%=GridGroupingControl1.ClientID%>'));
gridTable.HideColumn(0); //here 0 - column index which you want to hide
}
For your convenience we have modified the sample for the above scenario and it is attached below. Please refer to it.
Please let us know if you have any concerns.
Regards,
Rakesh D
Hi Sadagopan,
Thanks for your interest in Syncfusion products.
We have created a sample to your requirement in the incident ID #110415. Could you please follow up the incident.
Could you please use that sample and get back to us if you have any queries.
Let us know if you have any concerns.
Regards,
Ajith R