Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Insert New row into DataGrid

Status
Not open for further replies.

sahernandez

Programmer
Oct 1, 2002
69
SV
Hi.
I need to Insert a new Row into DataGrid how can I do this.
I know to Update, delete , etc, but I miss the Insert option, Any Idea.

Thxs.
Alexander
 
if your using datatables, you can insert a new row at the beginning or end just with a new row. dataTable.Rows.Add(dataRow)

you can then change the text from edit to new or insert with this

Private Sub dgrdEquipment_ItemCreated(ByVal sender As Object, ByVal e As DataGridItemEventArgs) Handles dgrdEquipment.ItemCreated
If e.Item.ItemIndex = 0 Then
Dim b As Button = CType(e.Item.Cells(0).Controls(0), Button)
If b.Text.Equals("Edit") Then
b.Text = "New"
chk.Visible = False
ElseIf b.Text.Equals("Update") Then
b.Text = "Insert"
End If
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top