urgent about DataGrid web control
-
-
hi all... I want to delete column in a datagrid at runtime. Can some body tell me how i can do this. I have read the topic given on this web sight. but that approach only hides the column from displaying. while i want to delete the whole column.
Why do u want to delete it? any particular reason? Hiding doesn't do it for you? "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
-
hi all... I want to delete column in a datagrid at runtime. Can some body tell me how i can do this. I have read the topic given on this web sight. but that approach only hides the column from displaying. while i want to delete the whole column.
You can delete the column with the Remove and RemoveAt methods of the DataGridColumnCollection class, for example:
private void DeleteColumn(int colIndex)
{
DataGrid1.Columns.RemoveAt(colIndex);
}However, you basically need to remove the column before the DataGrid control's state is reloaded and the control is rebuilt, otherwise it makes no changes to the column collection. In other words, you should remove the column in the Page_Init phase. So you'd better use the Visible property to display/hide a column. For more information see DataGridColumnCollection Class[^]
-
You can delete the column with the Remove and RemoveAt methods of the DataGridColumnCollection class, for example:
private void DeleteColumn(int colIndex)
{
DataGrid1.Columns.RemoveAt(colIndex);
}However, you basically need to remove the column before the DataGrid control's state is reloaded and the control is rebuilt, otherwise it makes no changes to the column collection. In other words, you should remove the column in the Page_Init phase. So you'd better use the Visible property to display/hide a column. For more information see DataGridColumnCollection Class[^]
As for as 'Rohan' message is concerned.... i want to delete the column... it is my need.... simply hiding the column doesn't satisfy my requirements.... and as for as minhpc_bk message is concerned.... i tried this approach.... but it is not working well...... Can u please tell me in detail what do u mean by 'datagrid state is reloaded '..... actually, i have a datagrid given...... I have to copy it into another datagrid with last column of first grid doesn't come to the second grid.... for this purpose what i have to do.....
-
As for as 'Rohan' message is concerned.... i want to delete the column... it is my need.... simply hiding the column doesn't satisfy my requirements.... and as for as minhpc_bk message is concerned.... i tried this approach.... but it is not working well...... Can u please tell me in detail what do u mean by 'datagrid state is reloaded '..... actually, i have a datagrid given...... I have to copy it into another datagrid with last column of first grid doesn't come to the second grid.... for this purpose what i have to do.....
amir_iiui wrote: Can u please tell me in detail what do u mean by 'datagrid state is reloaded '..... You can look at Control Execution Lifecycle[^] to see how a control is processed at the server side. amir_iiui wrote: I have to copy it into another datagrid with last column of first grid doesn't come to the second grid.... I am wondering why you have to copy a datagrid into another one, or in what situation you need to do that.