Guys, i have been struggling with this for past three days...
here is what i have...
aspx page
<form id="Form1" method="post" runat="server">
<asp:repeater id="titleRepeater" runat="server" EnableViewState="False">
<ItemTemplate>
<b><%# DataBinder.Eval(Container.DataItem,"Item_No") %>
<br>
</b>
<asp:DataGrid ID="maingrid" Runat="server" AutoGenerateColumns=True DataSource='<%# GetDataSource( Container.DataItem )%>' OnItemDataBound="maingrid_showformatting" ShowFooter=True >
</asp:DataGrid>
<br>
</ItemTemplate>
</asp:repeater></form>
codebehind
Private MyDataset As New DataSet
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
BindGrid()
End If
End Sub
Private Sub BindGrid()
Dim strConnection As String
strConnection = "conn string here"
Dim objConnection As OleDbConnection
objConnection = New OleDbConnection(strConnection)
objConnection.Open()
Dim StrSQL As String = "sql 1 here"
Dim strSQL1 As String = "sql 2 here"
Dim objDa As OleDbDataAdapter
Dim objDa1 As OleDbDataAdapter
objDa = New OleDbDataAdapter(StrSQL, objConnection)
objDa1 = New OleDbDataAdapter(strSQL1, objConnection)
objDa.Fill(MyDataset, "Parent")
objDa1.Fill(MyDataset, "Child")
titleRepeater.DataSource = MyDataset.Tables("Parent")
titleRepeater.DataBind()
End Sub
Public Function GetDataSource(ByVal dataItem As Object) As DataView
Dim intNo As String = DataBinder.Eval(dataItem, "Item_No")
Dim dv As DataView = MyDataset.Tables("Child").DefaultView
dv.RowFilter = "Item_No='" & intNo & "'"
Return dv
End Function
Sub maingrid_showformatting(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
'some formatting here
end sub
everything works fine...but i want to add subheader and break messages to the child datagrids that are created for the each repeater item...i am not sure how to reference them...here is what i am trying to add...the below is the code i have for a datagrid without repeater and works fine...but now i want to do the same thing for each datagrid inside repeater...
Dim row As TableRow
Dim i As Integer = 0
Do While i <= ds.Tables(0).Rows.Count - 2
If ds.Tables(0).Rows(i).Item("calcLength") Is DBNull.Value Then
Dim shRow As DataRow = ds.Tables(0).NewRow
shRow("Station") = "Subheading"
ds.Tables(0).Rows.InsertAt(shRow, i + 1)
i = i + 1
Else
Dim eRow As DataRow = ds.Tables(0).NewRow
eRow("calclength") = ds.Tables(0).Rows(i).Item("calcLength")
eRow("calcAve_Width") = ds.Tables(0).Rows(i).Item("calcAve_Width")
eRow("calcSF") = ds.Tables(0).Rows(i).Item("calcSF")
ds.Tables(0).Rows.InsertAt(eRow, i + 1)
i = i + 1
End If
i = i + 1
Loop
'End inserting break message
mydg.DataSource = ds
mydg.DataBind()
can some please assist me with this...