Edit this page

Insert/Update/Delete Using Controls API

Insert rows

Two general approaches in adding new rows exist. The first one is to add rows directly into the data source assigned to the grid (see RadGridView data binding). The second approach is to use the Add method of the Rows collection.

Adding rows to the rows collection

object[] row1 = new object[3];
row1[0] = 1;
row1[1] = "some text";
row1[2] = true;
// add first row
// add second row
radGridView1.Rows.Add(2, "another text", false);

Dim row1 As Object() = New Object(3) {}
row1(0) = 1
row1(1) = "some text"
row1(2) = True
' add first row
' add second row
RadGridView1.Rows.Add(2, "another text", False)

Update rows

The data in a row can be updated by assigning the new value to the GridViewCellInfo.Value property. The access to the GridViewCellInfos is through the Cells collection of each row (type GridViewRowInfo).

Before the value is set Validating event is fired. This event could be canceled to prevent updating the value in the cell. After the value update Validated event is fired.

Assigning value to a cell

radGridView1.Rows[0].Cells[0].Value = 4.3;
radGridView1.Rows[1].Cells["Column1"].Value = 114f;

RadGridView1.Rows(0).Cells(0).Value = 4.3
RadGridView1.Rows(1).Cells("Column1").Value = 114.0F

Delete rows

To delete row call GridViewRowCollection.Remove(GridViewRowInfo value) or GridViewRowCollection.RemoveAt(rowIndex).

Removing a row from the rows collection



See Also