|
OrderInfo newRow;
this.sfDataGrid1.AddNewRowPosition = RowPosition.FixedBottom;
this.sfDataGrid1.RowValidating += SfDataGrid1_RowValidating;
private void SfDataGrid1_RowValidating(object sender, RowValidatingEventArgs e)
{
newRow = e.DataRow.RowData as OrderInfo;
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(newRow.OrderID.ToString());
} |
|
Query |
Response |
|
If I have multiple lines added perhaps I need to add each variable for each new line. |
It is not possible to add another row using AddNewRow without committing the current editing row. So it doesn’t require multiple variables for adding multiple rows. |
|
if I'm not mistaken it is accessible from view but not from datasource, but when clear filter it is no longer available. Please clarify this. |
The new row added using AddNewRow will not be added to DataSource. It can be accessed only from SfDataGrid.View once the new row is committed.
We are unclear with your statement “but when clear filter it is no longer available.” If you are facing any problem related to filter, kindly replicate the issue in the sample we have provided in our previous update or use the sample link given below.
|
|
this.sfDataGrid1.RowValidated += OnSfDataGrid1_RowValidated;
private void OnSfDataGrid1_RowValidated(object sender, RowValidatedEventArgs e)
{
if(e.DataRow.RowType == RowType.AddNewRow)
{
list.Add(e.DataRow.RowData as OrderInfo);
}
} |
|
this.sfDataGrid1.RowValidating += OnSfDataGrid1_RowValidating;
private void OnSfDataGrid1_RowValidating(object sender, RowValidatingEventArgs e)
{
newRow = e.DataRow.RowData as OrderInfo;
if (this.sfDataGrid1.View.IsAddingNew)
this.sfDataGrid1.View.CancelNew();
if (e.DataRow.RowType == RowType.AddNewRow)
list.Add(newRow);
} |