dear,
I am using data table as source in datagrid. Data are displaying properly. Now I want to add new row as an unbound row. I already added Unbound row using
this.dataGrid.UnboundRows.Add(new GridUnboundRow() { Position = UnboundRowsPosition.Bottom });
Now I am going to save data in database but when I loop the grid, I don't get unbounded row count in
var records = dataGrid.View.Records;
I am not using any view model here. How to add unbound row in view?
I think there is refreshing issue but please help me out how to get it.
|
this.dataGrid.UnboundRows.Add(new GridUnboundRow() { Position = UnboundRowsPosition.Bottom });
var unboundRow = dataGrid.GetUnboundRowAtRowIndex(dataGrid.View.Records.Count + 1);
if(unboundRow != null)
{
// You can get the unboundrow
} |
Dear,
I am binding data table in data grid. for example there are 2 rows in data table. on binding data I get 2 count using
var records = dataGrid.View.Records ;
Now I want to add 3rd row as an unbound row. I added unbound row using
this.dataGrid.UnboundRows.Add(new GridUnboundRow() { Position = UnboundRowsPosition.Bottom } );
As per documentation, I read, the unbound row added as separately but not in data grid because when I loop data grid as shown in following Code, I got only 2 records.
var records = dataGrid.View.Records;
int nColCount = dataGrid.Columns.Count;
foreach (var record in records) {
var dataRowView = record.Data as DataRowView;
if (dataRowView != null) {
for (int iCtr = 0; iCtr < nColCount; iCtr++) {
}
}
}
As I understand that unbound row is actually not added/refreshed in our data grid.
Now my requirement is that newly added unbound row should be added in data grid in such a way that when I loop grid, it should show me record count to 3.
As per my requirement, SQL data table will not have fix no. of columns. So I am not using any view model.
So first thing how to update/refresh data grid rows on adding unbound row with data?
Second thing, I have already added unbound row and added value in some of columns, now I go to 2nd row which is from data table source binding, on changing any column of this row will remove data of unbound row.
So please suggest me the complete solution for above both problem.