Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
465
How can i add new empty row at the end of the webdatagrid
posted

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 .

Parents
No Data
Reply
  • 720
    Offline posted

    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

     

Children