i have doing windows application using vb.net 2010. i have 1 form, 1 gridview, 1 update/save button, 1 refresh button. in my code i can populate only 20 records and when i click next button it shows me the next 20 records. but my problem is code for update/save and refresh button. that means users can edit/delete/update/save data from the gridview. what i need is based on my code. thank you for your help. here is the code
Private Sub MDIParent1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
conn = GetConnect()
conn.Open()
str = "select [DocId],[Description] ,[Address] ,[NoOfPages] ,[SendOrReceived] ,[SentDate] ,[ReceivedDate] ,[ForwardedWorkingUnit] ,[Attachements] ,[ForwardedDate] ,[ReceivedBy] ,[LetterWrittenDate] ,[DocPath] FROM [Data].[dbo].[mytable]ORDER BY Id DESC"
com = New SqlCommand(str, conn)
oledbda = New SqlDataAdapter(com)
ds = New DataSet
oledbda.Fill(ds, i, 20, "mytable")
DataGridView1.DataSource = ds
DataGridView1.DataMember = "mytable"
conn.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
end sub
code for next button
Private Sub Nextrecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Nextrecord.Click
i = i + 20
If i > 23 Then
i = 18
End If
ds.Clear()
oledbda.Fill(ds, i, 20, "mytable")
End Sub
code for previous button
Private Sub PreviousRecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PreviousRecord.Click
i = i - 20
If i <= 0 Then
i = 0
End If
ds.Clear()
oledbda.Fill(ds, i, 20, "mytable")
End Sub