Datagrid inside repeater-simple reference problem

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2006
Posts: 7
Reputation: Eclipse414 is an unknown quantity at this point 
Solved Threads: 0
Eclipse414 Eclipse414 is offline Offline
Newbie Poster

Datagrid inside repeater-simple reference problem

 
0
  #1
Jan 10th, 2006
Guys, i have been struggling with this for past three days...

here is what i have...

aspx page
  1. <form id="Form1" method="post" runat="server">
  2. <asp:repeater id="titleRepeater" runat="server" EnableViewState="False">
  3. <ItemTemplate>
  4. <b><%# DataBinder.Eval(Container.DataItem,"Item_No") %>
  5. <br>
  6. </b>
  7. <asp:DataGrid ID="maingrid" Runat="server" AutoGenerateColumns=True DataSource='<%# GetDataSource( Container.DataItem )%>' OnItemDataBound="maingrid_showformatting" ShowFooter=True >
  8. </asp:DataGrid>
  9. <br>
  10. </ItemTemplate>
  11. </asp:repeater></form>

codebehind
  1. Private MyDataset As New DataSet
  2. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  3. If Not Page.IsPostBack Then
  4. BindGrid()
  5. End If
  6. End Sub
  7. Private Sub BindGrid()
  8. Dim strConnection As String
  9. strConnection = "conn string here"
  10. Dim objConnection As OleDbConnection
  11. objConnection = New OleDbConnection(strConnection)
  12. objConnection.Open()
  13. Dim StrSQL As String = "sql 1 here"
  14.  
  15. Dim strSQL1 As String = "sql 2 here"
  16.  
  17. Dim objDa As OleDbDataAdapter
  18. Dim objDa1 As OleDbDataAdapter
  19. objDa = New OleDbDataAdapter(StrSQL, objConnection)
  20. objDa1 = New OleDbDataAdapter(strSQL1, objConnection)
  21.  
  22. objDa.Fill(MyDataset, "Parent")
  23. objDa1.Fill(MyDataset, "Child")
  24.  
  25. titleRepeater.DataSource = MyDataset.Tables("Parent")
  26. titleRepeater.DataBind()
  27. End Sub
  28.  
  29. Public Function GetDataSource(ByVal dataItem As Object) As DataView
  30. Dim intNo As String = DataBinder.Eval(dataItem, "Item_No")
  31. Dim dv As DataView = MyDataset.Tables("Child").DefaultView
  32. dv.RowFilter = "Item_No='" & intNo & "'"
  33. Return dv
  34. End Function
  35. Sub maingrid_showformatting(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
  36. 'some formatting here
  37. end sub
  38.  

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...
  1. Dim row As TableRow
  2. Dim i As Integer = 0
  3.  
  4. Do While i <= ds.Tables(0).Rows.Count - 2
  5. If ds.Tables(0).Rows(i).Item("calcLength") Is DBNull.Value Then
  6. Dim shRow As DataRow = ds.Tables(0).NewRow
  7. shRow("Station") = "Subheading"
  8. ds.Tables(0).Rows.InsertAt(shRow, i + 1)
  9. i = i + 1
  10. Else
  11. Dim eRow As DataRow = ds.Tables(0).NewRow
  12. eRow("calclength") = ds.Tables(0).Rows(i).Item("calcLength")
  13. eRow("calcAve_Width") = ds.Tables(0).Rows(i).Item("calcAve_Width")
  14. eRow("calcSF") = ds.Tables(0).Rows(i).Item("calcSF")
  15.  
  16. ds.Tables(0).Rows.InsertAt(eRow, i + 1)
  17. i = i + 1
  18. End If
  19. i = i + 1
  20. Loop
  21. 'End inserting break message
  22.  
  23. mydg.DataSource = ds
  24. mydg.DataBind()
  25.  

can some please assist me with this...
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 7
Reputation: Eclipse414 is an unknown quantity at this point 
Solved Threads: 0
Eclipse414 Eclipse414 is offline Offline
Newbie Poster

Re: Datagrid inside repeater-simple reference problem

 
0
  #2
Jan 12th, 2006
please ignore this post...i got it solved...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC