View Single Post
  #9 (permalink)  
Old August 30th, 2005, 09:47 AM
ceema ceema is offline
Authorized User
Join Date: Aug 2005
Location: , , .
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts

quote:Originally posted by nashnash
 copy and paste the code is in ...

--Save this as 'WebForm1.aspx'---------------
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="VB.WebForm1"%>
<%@ Import Namespace="System.Data" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
        <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
        <meta name="CODE_LANGUAGE" Content="C#">
        <meta name="vs_defaultClientScript" content="JavaScript">
        <meta name="vs_targetSchema" content="">
    <body MS_POSITIONING="GridLayout">
        <form id="Form2" method="post" runat="server">
            <asp:repeater id="parentRepeater" runat="server">
                    <table border="1" width="300">
                            <td width="100"><b>Size</b></td>
                            <td width="100"><b>Stock</b></td>
                            <td width="100"><b>Price</b></td>
                    <table border="1" width="300">
                            <td width="100"><b><%# DataBinder.Eval(Container.DataItem,"Brand") %></b></td>
                            <td width="200" align="center"><b><%# DataBinder.Eval(Container.DataItem,"Code") %></b></td>
                    <asp:repeater id="childRepeater" datasource='<%# CType(Container.DataItem,DataRowView).CreateChildV iew("OrderRelation") %>' runat="server">
                            <table border="1" width="300">
                                    <td width="100"><%# DataBinder.Eval(Container.DataItem, "[size]")%></td>
                                    <td width="100"><%#CheckStock(Convert.ToInt32(DataBind er.Eval(Container.DataItem, "[stock]")))%></td>
                                    <td width="100"><%# DataBinder.Eval(Container.DataItem, "[price]")%></td>
                    </td> </tr>

--save this as 'WebForm1.aspx.vb' --------
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Public Class WebForm1
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents parentRepeater As System.Web.UI.WebControls.Repeater
    Protected WithEvents Repeater1 As System.Web.UI.WebControls.Repeater

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here

        Dim cnn As New SqlConnection("server=INSIGHT;UID=sa;PWD=Insight;d atabase=Pubs;")
        Dim ds As New DataSet
        Dim cmd1 As New SqlDataAdapter("select * from product", cnn)
        Dim cmd2 As New SqlDataAdapter("select * from stock", cnn)

        cmd1.Fill(ds, "product")
        cmd2.Fill(ds, "stock")
        ds.Tables(0).TableName = "product"
        ds.Tables(1).TableName = "stock"

        Dim Parent As DataColumn = ds.Tables("product").Columns("prod_id")
        Dim Child As DataColumn = ds.Tables("stock").Columns("prod_id")

        Dim ORelation As DataRelation = New DataRelation("OrderRelation", Parent, Child, False)

        parentRepeater.DataSource = ds.Tables("product")

    End Sub

    ' This function will take the stock and
    ' retrun you the label if there is Stock
    ' it will print Stock other wise it will
    ' print 'No Stock'

    Protected Function CheckStock(ByVal Stock) As String
        If (Stock > 0) Then
            Return Stock.ToString()

            Return "No Stock"
        End If

    End Function

End Class


Plz let me know if it works for you...


Hello Nash,

   I have tried the code but just like for Lofa, me too gets a blank page, could you please tell me what's wrong with the coding?