Visible Property of Repeater Control

Results 1 to 3 of 3

Thread: Visible Property of Repeater Control

  1. #1
    Join Date
    Dec 1969

    Default Visible Property of Repeater Control

    I have an asp script that needs to display certain elements ONLY if a certain condition is met, and then to NOT display those elements if the condition is not event.<BR><BR>specifically, this is a detail page that provides profile information on a database record. each record has a different collection of information. therefore, some records will use all of the controls on the detail page script, while other records will only use a couple of the controls. what i need to do is to set the "Visible" property of 2 repeater controls to be FALSE if a condition is not met.<BR><BR>my question is how to write the syntax for the conditional statement. I have seen syntax like:<BR><BR>IF ...<BR>MyRepeater.Visible = False<BR>END IF<BR><BR>to set the visibility property, but i need help with the IF line.<BR><BR>this is going to be set within the following SUB:<BR>-----------------------------------------------------------------<BR>Sub BindData(sqlString As String)<BR> Dim myConnection As SqlConnection <BR> Dim objDataset As DataSet <BR> Dim objSQLDataAdapter As SQLDataAdapter <BR> Dim myCommand As SqlCommand <BR><BR> Dim CenterStatus As String<BR> CenterStatus = "Active"<BR> myConnection = New SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))<BR> myConnection.Open() <BR><BR> objSQLDataAdapter = New SqlDataAdapter() <BR> objDataset = New DataSet() <BR><BR> Dim strSQL as String = sqlString<BR><BR> myCommand = New SqlCommand(strSQL, myConnection) <BR> myCommand.CommandType = CommandType.Text <BR><BR> objSQLDataAdapter.SelectCommand = myCommand <BR> objSQLDataAdapter.Fill(objDataset, "FAQs") <BR><BR> MyRepeater.DataSource = objDataset.Tables("FAQs") <BR> MyRepeater.DataBind()<BR>End Sub<BR>-----------------------------------------------------------------<BR>can anyone show me how to write the IF statement to properly check to see if the DataSet is empty?<BR><BR>Where do i add the IF statement and what does it need to look like in order to set "MyRepeater.Visible = False" ONLY in the event that the DataSet is empty?

  2. #2
    Join Date
    Dec 1969

    Default RE: Visible Property of Repeater Control

    If DataSet.Tables("TableName").Rows.Count = 0<BR>MyRepeater.Visible = False<BR>Else<BR>&#039;other code...<BR>End if

  3. #3
    Join Date
    Dec 1969

    Default Use MyRepeater.Items.Count

    If MyRepeater.Items.Count = 0 Then<BR> MyRepeater.Visible = False<BR>End If<BR><BR>or how about<BR><BR>MyRepeater.Visible = (MyRepeater.Items.Count &#062; 0)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts