#Region "Using ItemCommand to start to bind child DataList"
Private Sub dlstGroup_ItemCommand(ByVal [source] As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dlstGroup.ItemCommand
'-----------------------------------------------
'Show the child datalist and bind it.
'-----------------------------------------------
If (e.CommandName = "carryout") Then
For Each dgi As DataListItem In Me.dlstGroup.Items
'Only find the current item's child datalist.
If (dgi.ItemIndex = e.Item.ItemIndex) Then
Dim lb As Label = CType(dgi.FindControl("lblMyClientCode"), Label) 'find clientcode lable.
Dim objDataList As DataList = CType(dgi.FindControl("dlstChild"), DataList) 'find the child datalist.
Dim imgBtnOut As ImageButton = CType(dgi.FindControl("imgbtnPlus"), ImageButton) 'find the imgbtn "+"
Dim imgBtnIn As ImageButton = CType(dgi.FindControl("imgbtnFminus"), ImageButton) 'find the imgbtn "-"
Dim strClientCode As String
'find the lable whose text is the clientcode.
If Not (lb Is Nothing) Then
strClientCode = lb.Text.Trim()
End If
'Bind the child datalist if find it.
If Not (objDataList Is Nothing) Then
objDataList.Visible = True
Try
BindDataListChild(objDataList, strClientCode, ViewState("ProjectCode"), ViewState("Range"), ViewState("NiHon"), ViewState("DelFlag"))
Catch ex As Exception
Response.Redirect(lStrErorrPage)
'add log
End Try
End If
'Set the imagebtn's property.
If Not (imgBtnOut Is Nothing) Then
imgBtnOut.Visible = False
End If
If Not (imgBtnIn Is Nothing) Then
imgBtnIn.Visible = True
End If
End If
Next
End If
'-----------------------------------------------
'Unvisible the child datalist
'-----------------------------------------------
If (e.CommandName = "carryin") Then
For Each dgi As DataListItem In Me.dlstGroup.Items
'find the child data list in the just item,and set the unvisible property.
If (dgi.ItemIndex = e.Item.ItemIndex) Then
Dim objDataList As DataList = CType(dgi.FindControl("dlstChild"), DataList) 'find the child datalist.
Dim imgBtnOut As ImageButton = CType(dgi.FindControl("imgbtnPlus"), ImageButton) 'find the imgbtn "+"
Dim imgBtnIn As ImageButton = CType(dgi.FindControl("imgbtnFminus"), ImageButton) 'find the imgbtn "-"
objDataList.Visible = False
If Not (imgBtnOut Is Nothing) Then
imgBtnOut.Visible = True
End If
If Not (imgBtnIn Is Nothing) Then
imgBtnIn.Visible = False
End If