nkwk Posted April 29, 2004 Posted April 29, 2004 I've written a couple of windows based database apps now which would usually use this code to navigate to the next record: Me.BindingContext(DataSet1, "mailinglist").Position = (Me.BindingContext(DataSet1, "Mailinglist").Position + 1) But in asp.net this isnt possible. My feeble code currently exists of: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load SqlDataAdapter1.Fill(DataSet11) TextBox1.DataBind() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click End Sub This has bound a textbox to the dataset. How would i navigate to the next record in the dataset? Nick Quote
Arch4ngel Posted April 29, 2004 Posted April 29, 2004 A DataSet is made of Tables (ds.Tables) And a Table is made of Columns and Rows (.Rows .Columns) You can index them with (x) where x is an integer or , in the case of Columns, the ColumnName. Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
nkwk Posted April 30, 2004 Author Posted April 30, 2004 Man ... i'm seriously stuck. Could someone explain this to me. I keep seeing references to datagrid's everywhere. But i'm not use if thats what i want. I'm just trying to create a basic webform that will navigate records on the sql server. So textbox1 would read record one on load. Then when you hit next Textbox1 displays record 2. I cant find example coding anywhere for the next button :( nick Quote
Administrators PlausiblyDamp Posted April 30, 2004 Administrators Posted April 30, 2004 (edited) Web applications behave differently from Windows applications. A windows application will maintain state as long as the application is running and as such will persist the DataSet between button clicks. Web applications however lose their state between postbacks (button clicks etc) and will require either the DataSet to be recreated on each page refresh or for it to be deliberately stored on the server (probably as a Session, Application or Cache variable, depending on your requirements). To allow a simple Next button to work you would need to store the current position in the DataSet so it could be accessed across postbacks (probably using Session, ViewState or QueryString). This would need to be read each time the page is refreshed and the appropriate data retrieved and used to populate the page. Edited March 30, 2007 by PlausiblyDamp Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
nkwk Posted April 30, 2004 Author Posted April 30, 2004 I'm going to try and use a session called "index" which will store on button_click and retrieve on page load. Quote
nkwk Posted April 30, 2004 Author Posted April 30, 2004 Sorry for keep coming back and forth but i don't have a clue lol. I'm figuring it out as i go along. How do i make the dataset goto the position that i have stored? Say I wanted it to goto record 10. Its not dataset11.tables(0).rows(10) (lost) Nick Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.