In Visual Basic 2010 How do I delete a row in a DataRepeater Using a button,
-
Tuesday, June 28, 2011 1:59 PM
Hi Good People
How do I delete a row In a Datarepeater1 using a Button (Button6). On my form Called DailyJobsForm I have a DataRepeater1 and in the DataRepeater1. I have a row with.. (ViewJob "Button"), (BookingDate "TextBox"), (BookingTime "TextBox"), (VehicleType "TextBox"), (NameNumber"TextBox2), (DestinationFrom "TextBox"), (DestinationTo "TextBox), (TotalFare "TextBox"), (Driver "ComboBox"), (Allocate "Button") and (Notes "TextBox").
and At the Bottom of the DailyJobsform I have The Button6. and When I click this Button6 I want to delete/Remove the selected row in the DataRepeater1 and save the data to a form Called Deleted Jobs Form.
I have tried different combinations. of code from a button click event to Datarepeater1.change with no success. Can you please Help
Kind Regards
Gary
Gary Simpson
All Replies
-
Wednesday, June 29, 2011 2:23 PM
-
Thursday, June 30, 2011 6:40 AMModerator
Hi Gary,
Welcome to the MSDN Forum again.
Based on my experience, I recommand you :
1. delete the item in a datasource of the datarepeater, and put the item in a temporary variable.
2. and then reset the datarepeater datasource.
3. Add the tempopray variable item to the deleted Daily job form.
Please try it, if you have further concerns, please feel free to let me know.
Best regards,
Mike Feng [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

-
Friday, July 01, 2011 7:38 PM
Hi Mike Feng
1) How do I create A temporary variable
2) And as For, Add the tempopray variable item to the deleted Daily job form.
The Daily Jobs From has a the datarepeater that will show all the jobs. How/what would you suggest to use if I delete the Datarepeater.
or Maybe I have the wrong end of the stick
Best Regards
Gary
Gary Simpson -
Monday, July 04, 2011 1:30 AMModerator
Hi Gary,
Please take a look at the following code:
Public Sub DeleteItem() 'create the trmporary variable Dim tr As DataRow = DeleteForm.datatable1.NewRow tr.ItemArray = Me.dataTabl1.Rows(Me.DataRepeater1.CurrentItemIndex).ItemArray 'delete the item from the dailyJob Form Me.dataTabl1.Rows(Me.DataRepeater1.CurrentItemIndex).Delete() 'reset the datasource of the datarepeater in dailyJob Form Me.DataRepeater1.DataSource = Nothing Me.DataRepeater1.DataSource = Me.dataTabl1 'add the new Item to the DeleteForm DeleteForm.datatable1.Rows.Add(tr) 'reset the datasource of the datarepeater in the DeletedJob Form DeleteForm.DataRepeater1.DataSource = Nothing DeleteForm.DataRepeater1.DataSource = DeleteForm.datatable1 End Sub
If I am unclear, please just tell me, I will try to explain it in more details.Best regards,
Mike Feng [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

- Marked As Answer by Mike FengMicrosoft Contingent Staff, Moderator Monday, July 11, 2011 8:17 AM


