
May 1st, 2003, 09:01 PM
|
|
Registered User
|
|
Join Date: Jan 2003
Posts: 26
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Displaying record # for each record in a datalist
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><div class="msgQuoteWrap"><div class="msgCode"><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("Server=SQLSALESDEV;Database=users;UID=u87594;Passw ord=afton;")<br> Dim objDA As New SqlDataAdapter("SELECT contactID_pk, name, message, dateCreated FROM contactUs", objConn)<br> Dim objDS As New DataSet()<br><br> If Not Page.IsPostBack() Then<br> Dim intCounter As Integer '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> '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> 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></div></div><br>What’s the matter with what I’m doing?
|