Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid or Datagrid inside datalist/repeater - Part 3 1

Status
Not open for further replies.

DotNetGnat

Programmer
Mar 10, 2005
5,548
IN
ca8msm,

First of all thanks so much for helping me out on this one...

Here is the code i have so far...

aspx
Code:
<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>

code behind

Code:
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 = "my conn string"
        Dim objConnection As OleDbConnection
        objConnection = New OleDbConnection(strConnection)
        objConnection.Open()
        Dim MyDataRow As DataRow
        Dim StrSQL As String = "my sql1"

        Dim strSQL1 As String = "my sql 2"

        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 i As Integer = 0
        Dim intNo As String = DataBinder.Eval(dataItem, "Item_No")
        Dim dv As DataView = MyDataset.Tables("Child").DefaultView
        dv.RowFilter = "Item_No='" & intNo & "'"
    End Function

'for some formatting...

Sub maingrid_showformatting(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
        e.Item.Cells.RemoveAt(9)

        e.Item.Cells(1).Text = DataBinder.Eval(e.Item.DataItem, "calcLength", "{0:#,###}")
        e.Item.Cells(2).Text = DataBinder.Eval(e.Item.DataItem, "Width", "{0:#,###}")
end sub

works perfect...all the child datagrids are correctly populated with
inside the repeater...no problem there...

[red]can you please show me how to reference each dataview and where
to add/insert rows and do formatting...
[/red]

Thanks so much...

-DNG
 
Finally solved the problem in .net too...was simply not understanding the simple thing...thanks

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top