Displaying a record number for each record in a da

Results 1 to 2 of 2

Thread: Displaying a record number for each record in a da

  1. #1
    Join Date
    Dec 1969

    Default Displaying a record number for each record in a da

    I’ve got a working datalist going; the only thing is that I can’t seem to display properly the record number for each record. I’m trying to use a For...Next loop within an If Not Page.IsPostBack and I keep getting an error. Here is my code.<BR><BR> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<BR> If Not Page.IsPostBack() Then<BR> lblPageSize.Text = "5"<BR> lblCurrIndex.Text = "0"<BR> SQLBind()<BR> End If<BR> End Sub<BR><BR> Private Sub SQLBind()<BR> Dim objConn As New SqlConnection("My connection info;")<BR> Dim objDA As New SqlDataAdapter("SELECT name, message, dateCreated FROM contactUs", objConn)<BR> Dim objDS As New DataSet()<BR><BR> If Not Page.IsPostBack() Then<BR> Dim intCounter As Integer &#039;Holds counter for loop<BR> Dim intNewCounter As Integer = 1<BR> objDA.Fill(objDS)<BR> lblRecordCount.Text = CStr(objDS.Tables(0).Rows.Count)<BR><BR> &#039;My record counter loop<BR> For intCounter = 0 To objDS.Tables(0).Rows.Count - 1<BR> lblFrIntCounter.Text = lblFrIntCounter.Text & intNewCounter.ToString<BR> intNewCounter += 1<BR> Next<BR><BR> objDS = Nothing<BR> objDS = New DataSet()<BR> End If<BR><BR> objDA.Fill(objDS, CInt(lblCurrIndex.Text), CInt(lblPageSize.Text), "contactUs")<BR> dblDisplay.DataSource = objDS.Tables(0).DefaultView<BR> dblDisplay.DataBind()<BR> objConn.Close()<BR> PrintStatus()<BR> End Sub<BR><BR>What’s the matter with what I’m doing?

  2. #2
    Join Date
    Dec 1969

    Default RE: Displaying a record number for each record in

    This question has been answered here:<BR>http://asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=208405

Posting Permissions

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