User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 427,939 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,827 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 537 | Replies: 1
Reply
Join Date: Jun 2008
Posts: 25
Reputation: preethi_ga is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
preethi_ga preethi_ga is offline Offline
Light Poster

Next, Previous buttons in ASP.NET.

  #1  
Jul 8th, 2008
Hei,
Im using ASP.NET as Front end and SQL Server as Backend. the codings are..
  1. imports system
  2. imports system.data
  3. imports system.data.sqlclient

After inherits...... some connectin codingd are there
  1. dim con as SqlConnection
  2. dim adp as SqlDataAdapter
  3. dim com as SqlCommand
  4. dim data as Dataset
after the connection codings in Next button the following codings im writing....
  1. dim rec_count as integer = 0
  2. dim row_count as integer = data.Tables(0).Rows.Count - 1 // so by this we will get total number of records.
  3. If rec_count <> row_count Then
  4. rec_count = rec_count + 1
  5. TextBox1.Text = Data.Tables(0).Rows(rec_count).Item(0)
  6. TextBox2.Text = Data.Tables(0).Rows(rec_count).Item(1)
  7. Else
  8. MsgBox " This is the Last Record "
Like wise im writing for PREVIOUS BUTTON also, only change is [ rec_count = rec_count - 1 ] By writing this,,, when the first time i click in the Next button , it goes to next record, but when next time i click in Next button ... it doesnt change.
then if i click in PREVIOUS button... It shows error like... "There is no record in position -1".
So many times i asked about this? but im not getting the correct solution. So any one Please get me correct soution??
Last edited by peter_budo : Jul 9th, 2008 at 6:41 am. Reason: Correcting code tags, please use as follows [code]YOUR CODE HERE[/code]
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2007
Location: Surathkal
Posts: 106
Reputation: tuse is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 10
tuse's Avatar
tuse tuse is offline Offline
Junior Poster

Re: Next, Previous buttons in ASP.NET.

  #2  
Jul 8th, 2008
Well when you click on the button, the page is posted back to the server and you start again with rec_count as 0.

Thus when you click on the Next button, you see only your first record and when you say previous (which is again a button click), it does 0-1= -1 and does not find any corresponding record at that position.

You need to know about State Management in order to get this code working for you. I suggest you store your table in a Session Variable and access it using individual datarows of a datatable.

PS- ASP.NET does not quite work the same way as VB.NET!
Last edited by tuse : Jul 8th, 2008 at 7:56 am.
My blog on .NET- http://dotnet.tekyt.info
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 6:33 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC