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.
What’s the matter with what I’m doing? ![[sadeyes] [sadeyes] [sadeyes]](/data/assets/smilies/sadeyes.gif)
JJ![[peace] [peace] [peace]](/data/assets/smilies/peace.gif)
"Ignorance and prejudice and fear walk hand in hand" - Witch Hunt, by Rush
Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack() Then
lblPageSize.Text = "5"
lblCurrIndex.Text = "0"
SQLBind()
End If
End Sub
Private Sub SQLBind()
Dim objConn As New SqlConnection("My connection info")
Dim objDA As New SqlDataAdapter("SELECT contactID_pk, name, message, dateCreated FROM contactUs", objConn)
Dim objDS As New DataSet()
If Not Page.IsPostBack() Then
Dim intCounter As Integer 'Holds counter for loop
Dim intNewCounter As Integer = 1
objDA.Fill(objDS)
lblRecordCount.Text = CStr(objDS.Tables(0).Rows.Count)
'My record counter loop
For intCounter = 0 To objDS.Tables(0).Rows.Count - 1
lblFrIntCounter.Text = lblFrIntCounter.Text & intNewCounter.ToString
intNewCounter += 1
Next
objDS = Nothing
objDS = New DataSet()
End If
objDA.Fill(objDS, CInt(lblCurrIndex.Text), CInt(lblPageSize.Text), "contactUs")
dblDisplay.DataSource = objDS.Tables(0).DefaultView
dblDisplay.DataBind()
objConn.Close()
PrintStatus()
End Sub
![[sadeyes] [sadeyes] [sadeyes]](/data/assets/smilies/sadeyes.gif)
JJ
![[peace] [peace] [peace]](/data/assets/smilies/peace.gif)
"Ignorance and prejudice and fear walk hand in hand" - Witch Hunt, by Rush