Multiple tables not displayed when binding to a Repeater

Discussion in 'ASP .Net' started by Jim French, Jul 18, 2003.

  1. Jim French

    Jim French Guest

    I have a page that takes a comma delimited string and needs to bind to a
    Repeater control. The string is split into an Array, and each value is put
    into a DataBase query via a For Each loop. The purpose is to retrieve
    address information for the user. Sometimes, the address_fk field in the
    people table is null, so there will be no linking address information. In
    this case, the section to be displayed asks if the user would like to create
    an address. (The section information is not shown.)

    If the first array variable contains an id with an associated address, no
    problem - the page acts correctly. The problem I have is that if the first
    variable passed does not retrieve any rows from the address table, then the
    second query (which does have values in the address table) is not displayed.
    The If clause in the Page_Load event below is to retrieve the People ID
    field, which must be shown in the Repeater section whether there is an
    associated address or not.

    I have verified that all works as I think it should up until the DataBind
    method. Right before I bind to the Repeater, the row count is correct (0,2
    respectively), and the table count is correct (2). But when I bind, only the
    first row (no address data) is displayed. The Repeater only fires once, and
    never fires for the second DataSet table, the one with values. What is
    happening here?

    (In the If clause, I clear the columns in the table because certain controls
    in the Repeater are hidden based on the number of rows returned. If one row
    is returned, it checks to see if there is one column (no address
    information) or nine columns (there is address info.) If you need to see
    further information, please let me know.)

    Thank you very much,

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    If Not Page.IsPostBack Then
    Session("myVars") = "46,44"

    'Split the array
    strArray = Session("myVars").ToString.Split(",")

    'Declare database variables
    objConn = New OleDbConnection(Application("dbString"))
    objComm = New OleDbCommand(strSQL, objConn)
    objDS = New DataSet()

    'Loop through the addresses of each party
    For Each strTemp In strArray
    strSQL = "select,name,Address1,Address2,City,State_ID_Fk,Zip_Code, as
    PeopleID,pa.id_number " _
    & "from Address ad, People_Address pa where pa.id_number =
    ad.ID_Number " _
    & "and = " & strTemp

    objAdp = New OleDbDataAdapter(strSQL, objConn)
    objAdp.Fill(objDS, strTemp)

    'If there are no rows, then repopulate with a new query
    because the Repeater
    'needs to have rows to work with
    If objDS.Tables(strTemp).Rows.Count = 0 Then
    strSQL = "select id_number from caseflow.people_address
    where " _
    & "address_fk is null and id = " & strTemp
    objAdp.SelectCommand.CommandText = strSQL
    End If

    Response.Write("<br>My count = " & objDS.Tables.Count)
    Repeater1.DataSource = objDS
    End If
    End Sub
    Jim French, Jul 18, 2003
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew Chalk
    Andrew Chalk
    Oct 24, 2005
  2. =?Utf-8?B?S2lt?=

    Data not displayed in Repeater

    =?Utf-8?B?S2lt?=, Dec 1, 2005, in forum: ASP .Net
    Dec 6, 2005
  3. boney
  4. Replies:
  5. Andrew Chalk

    Sorting a dataset displayed using a repeater

    Andrew Chalk, Oct 24, 2005, in forum: ASP .Net Web Controls
    Andrew Chalk
    Oct 24, 2005

Share This Page