The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
I was wondering if anyone could help me change the value of a cell''s datasource, in a GridDataboundGrid, at runtime. I would like to use a default datasouce for the column, but be able to change the datasource if the user checks a box in a column in the same row. I have tried the following, but it does not work:
private void gdbServer_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
int row = e.RowIndex;
int col = e.ColIndex;
if ( col == 2 && row > 0 )
{
string sPass = this.gridDataBoundGrid[ row, 3 ].CellValue.ToString();
if ( sPass == "N" )
{
e.Style.DataSource = this.dataViewA;
}
if ( sPass == "Y" )
{
e.Style.DataSource = this.dataViewB;
}
}
}
ADAdministrator Syncfusion Team February 23, 2004 04:18 PM UTC
Try using the grid.Model.QueryCellInfo event instead of the grid.PrepareViewStyleInfo event.
If that does not work for you, you can use the grid.CurrentCellShwoingDropDown event as discussed in this KB, http://www.syncfusion.com/Support/article.aspx?id=567
ADAdministrator Syncfusion Team February 23, 2004 05:41 PM UTC
Thanks, the CurrentCellShowingDropDown event worked for me. Here is how I did it, in case anyone else is curious.
private void gdbServer_CurrentCellShowingDropDown(object sender, Syncfusion.Windows.Forms.Grid.GridCurrentCellShowingDropDownEventArgs e)
{
GridCurrentCell cc = this.gdbServer.CurrentCell;
int row = cc.RowIndex;
int col = cc.ColIndex;
if( col == 2 )
{
GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer;
if( cr != null )
{
string sPass = this.gridDataBoundGrid[ row, 3 ].CellValue.ToString();
if ( sPass == "N" )
{
((GridComboBoxListBoxPart)cr.ListBoxPart).DataSource = this.dataViewA;
}
if ( sPass == "Y" )
{
((GridComboBoxListBoxPart)cr.ListBoxPart).DataSource = this.dataViewB;
}
}
}
}