This is a migrated thread and some comments may be shown as answers.

[Solved] call delete in grid 2 from grid 1

3 Answers 95 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chom
Top achievements
Rank 1
Chom asked on 19 Feb 2010, 06:45 PM
Hi all

I have 2 grids on my page, grid1 and grid2. I have a row delete button in grid1. When I click on this delete button I delete the row in grid1 and in my stored proc I also delete any associated data in another table which is grid2.

I am calling the delete button in code behind from the _ItemCommand event of grid1.

 

Protected Sub rgListingWithImages_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgListingWithImages.ItemCommand

 

 

'1. Check which alpha character was selected and then rebind the data to the grid

 

 

'2. Redirect to another page when SalesID, Email, Notes or PwdReset is selected

 

 

Dim value As String = Nothing

 

 

Select Case e.CommandName

 

 

Case ("DeleteRow")

 

 

Dim myItem As GridDataItem = DirectCast(e.Item, GridDataItem)

 

 

Dim CustID As TableCell = myItem("CustomerID")

 

 

Dim OrdID As TableCell = myItem("OrderID")

 

 

Dim ListNo As TableCell = myItem("BusinessListingNumber")

 

 

'Delete specific listing row with slides WS = with slides

 

 

Dim BusList As New BusinessListingsPlanAndPricing

 

BusList.DeleteOneRowInBusinessListings(CustID.Text, OrdID.Text,

CInt(ListNo.Text), "WS")

 

 

'Display listings

 

LoadListingsGridWithSlides()

 

'Price

 

CalculateBusinessCostAndDisplay()

LoadSlidesGrid()

 

Exit Select

 

 

Case ("Select")

 

 

 

Exit Select

 

 

End Select

 

 

End Sub

 



Heres my issue: The data is deleted from the database but grid2 is still displaying the data. I have call a subroutine to refresh the grid datasource but this does not work. It only clears when I click on a delete button in grid2.

How do I call the delete event in grid2 from grid1 to refresh grid2?

many thanks

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 20 Feb 2010, 06:29 AM
Hi,

Are you binding the Grid using the  Advanced data-binding techniques? If so then calling RadGrid2.Rebind() on delete command of RadGrid1 should work fine. Also make sure that if you are using an Ajax manager that you set the Ajax settings correctly.
You can refer to the link below,for  more info on the same:

Thanks,
Princy
0
Chom
Top achievements
Rank 1
answered on 20 Feb 2010, 10:16 PM
Hi Princy

I have looked at the advanced binding technique. I think that this is something I am going to have to start with again. I think I have gotten into a corner and I am struggling to get out. I am using the itemcommand event to to send some parameters from the grid to a class which calls some stored procedures etc. From this a datatable is created which is called by these other events of the grid:

SortCommand

 

SelectedIndexChanged

 

PageIndexChanged

I tried using the NeedsDatasource event but that event is called when the page loads and my stored procs have no parameters and I get an error.

I have spent a lot of tme on it for now. I think that I am going to take a different approach and then revisit when I have time.

Thanks for your help.

0
Chom
Top achievements
Rank 1
answered on 22 Feb 2010, 10:54 PM
Hi Princy

I got it figured. I re-did everything and configured the grids to use SQLdatasources in the aspx markup. I was doing all of this in code behind and it became a nighmare. The code behind has now been considerable reduced and more manageable. Everything is updating correctly and the delete functions are working great.

Thanks for your help.
Chommy
Tags
Grid
Asked by
Chom
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Chom
Top achievements
Rank 1
Share this question
or