Let me first start with...I am teaching myself .net Now, having said that...I have a page that contains a 3-level nested gridview:
parent
child
grandchild
For the most part..it works. The parent and child grids both work perfectly. The grandchild however, is causing some issues. I am able to add a record and delete a record from the grandchild grid but I cannot enter edit mode. While stepping through the code, I have determined that the DataBind methods are not actually calling the RowDataBound event. They are not erroring out, not being skipped, just not going anywhere. While stepping through the code, I go to that line, then immediately go to the next line instead of going to the RowDataBound event. I have no idea why! Part of my code is below...if you need more let me know. I appreciate any help you can offer!
I am also declaring the following global variables:
Private gvUniqueID As String = [String].Empty
Private gvNewPageIndex As Integer = 0
Private gvEditIndex As Integer = -1
Private gvSortExpr As String = [String].Empty
Private gvUniqueID1 As String = [String].Empty
Private gvNewPageIndex1 As Integer = 0
Private gvEditIndex1 As Integer = -1
Private gvSortExpr1 As String = [String].Empty
Private RecurringEventRecordNo As Integer = 0
'Public WithEvents gvDirective As UserControl
Dim WithEvents gvDirective As New GridView
Dim WithEvents gvTask As New GridView
Any idea why the code works in the parent and child but not the grandchild gridview? Thanks!
Brenda
parent
child
grandchild
For the most part..it works. The parent and child grids both work perfectly. The grandchild however, is causing some issues. I am able to add a record and delete a record from the grandchild grid but I cannot enter edit mode. While stepping through the code, I have determined that the DataBind methods are not actually calling the RowDataBound event. They are not erroring out, not being skipped, just not going anywhere. While stepping through the code, I go to that line, then immediately go to the next line instead of going to the RowDataBound event. I have no idea why! Part of my code is below...if you need more let me know. I appreciate any help you can offer!
Code:
Protected Sub gvTask_RowEditing(ByVal sender As Object, ByVal e As GridViewEditEventArgs)
Dim gvTemp3 As GridView = DirectCast(sender, GridView)
gvUniqueID1 = gvTemp3.UniqueID
gvEditIndex1 = e.NewEditIndex
gvDirective.DataBind()
End Sub
Code:
Protected Sub gvDirective_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles gvDirective.RowDataBound
Dim row As GridViewRow = e.Row
Dim strSort As String = String.Empty
'Check if this is our Blank Row being databound, if so make the row invisible
If e.Row.RowType = DataControlRowType.DataRow Then
If DirectCast(e.Row.DataItem, DataRowView)("Directive_No").ToString() = "0" Then
e.Row.Visible = False
End If
End If
' Make sure we aren't in header/footer rows
If row.DataItem Is Nothing Then
Exit Sub
End If
'Find Child GridView control
Dim gv3 As New GridView()
gv3 = DirectCast(row.FindControl("gvTask"), GridView)
'Check if any additional conditions (Paging, Sorting, Editing, etc) to be applied on child GridView
If gv3.UniqueID = gvUniqueID Then
gv3.PageIndex = gvNewPageIndex
gv3.EditIndex = gvEditIndex
'Check if Sorting used
If gvSortExpr1 <> String.Empty Then
GetSortDirection()
strSort = " ORDER BY " & String.Format("{0} {1}", gvSortExpr1, gvSortDir)
End If
'Expand the Child grid
ClientScript.RegisterStartupScript([GetType](), "Expand", "<SCRIPT LANGUAGE='javascript'>expandcollapse2('div" & DirectCast(e.Row.DataItem, DataRowView)("Directive_ID").ToString() & "','one');</script>")
End If
'Prepare the query for Child GridView by passing the Directive_ID of the parent row
gv3.DataSource = ChildDataSource2(DirectCast(e.Row.DataItem, DataRowView)("Directive_No").ToString(), strSort)
gv3.DataBind()
End Sub
I am also declaring the following global variables:
Private gvUniqueID As String = [String].Empty
Private gvNewPageIndex As Integer = 0
Private gvEditIndex As Integer = -1
Private gvSortExpr As String = [String].Empty
Private gvUniqueID1 As String = [String].Empty
Private gvNewPageIndex1 As Integer = 0
Private gvEditIndex1 As Integer = -1
Private gvSortExpr1 As String = [String].Empty
Private RecurringEventRecordNo As Integer = 0
'Public WithEvents gvDirective As UserControl
Dim WithEvents gvDirective As New GridView
Dim WithEvents gvTask As New GridView
Any idea why the code works in the parent and child but not the grandchild gridview? Thanks!
Brenda