hi,
iam autogenerating the columns in the webdatagrid and want to add a new empty row in the WebDatagrid with server side by pressing a button.
The new row should be added at the bottom of the WebDatagrid .
Hello Mark,
In order to add a new empty row in the WebDataGrid you have to execute the following code in the button click event handler. Note that if the WebDataGrid has a primaryKey set, you can’t leave the respective field empty.
private void AddRow(object sender, EventArgs e) { DataRow row = (WebDataGrid1.DataSource as DataTable).NewRow(); //row["id"] = (WebDataGrid1.DataSource as DataTable).Rows.Count + 1; (WebDataGrid1.DataSource as DataTable).Rows.Add(row); }
You can find additional information about the row adding in this topic.
Thank you for using our product, if you have any further questions please contact me!
Best Regards,
Martin Evtimov
it worked but i need to select the new row after adding it ; i used :
var lenght = WebDataGrid1.Rows.Count;
SelectedRowCollection selectedRows = this.WebDataGrid1.Behaviors.Selection.SelectedRows; selectedRows.Add(this.WebDataGrid1.Rows[lenght]);
but this didn't work. i want to select the new row and active any cell after adding it.
what am i doing wrong ?