ItemDataBound to Grid Within Repeater
Hi,
Any help with this is very much appreciated.
I have a datagrid within a repeater that is working fine. The problem that I'm having is that I need to add totals to the footer of the datagrid. You can see in the red code below what I have tried but on debugging it never enters the ItemDataBound Sub.
Protected Sub btnSearch_OnClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnSearch.Click
Try
_oConn.Open()
Dim SQL As String = "Some SQL Query;"
Dim CMD As SqlCommand = New SqlCommand(SQL, _oConn)
CMD.Parameters.AddWithValue("@InqStart", txtInqStart.Text)
CMD.Parameters.AddWithValue("@InqFinish", txtInqFinish.Text)
Dim oDA As New SqlDataAdapter(CMD)
Dim oDS As New DataSet
oDA.Fill(oDS)
rptAgencyDetail.DataSource = oDS
rptAgencyDetail.DataBind()
Catch ex As Exception
Session("AlertPass") = False
Session("AlertText") = ex.Message
Finally
_oConn.Close()
End Try
End Sub
Protected Sub rptAgencyDetail_ItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs) Handles rptAgencyDetail.ItemDataBound
Try
_oConn.Close()
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
Dim grdInquiryDetails As DataGrid = e.Item.FindControl("grdInquiryDetails")
Dim SQL As String = "Some SQL Query;"
Dim oDA As New SqlDataAdapter(SQL, _oConn)
Dim oDS As New DataSet
oDA.Fill(oDS)
grdInquiryDetails.DataSource = oDS
grdInquiryDetails.DataBind()
AddHandler grdInquiryDetails.ItemDataBound, AddressOf grdInquiryDetails_ItemDataBound
End If
Catch ex As Exception
Session("AlertPass") = False
Session("AlertText") = ex.Message
Finally
DBCount = 0
End Try
End Sub
Protected Sub grdInquiryDetails_ItemDataBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs) Handles grdInquiryDetails.ItemDataBound
If e.Item.ItemType = ListItemType.Footer Then
e.Item.Cells(0).Text = grdInquiryDetails.Items.Count
End If
End Sub
Anybody got any ideas? Sure would be appreciated.
Thank you,
Richard
|