This code is for to get the first,last,previous,next records..... ================================================================== If we want to see the next,previous,first,last means we will use code like ,
int n=0;//global declaration datatable dt; form_load() { con............... ................//connection whatever you want... sqldataadapter da=new sqldataadapter("select * from ",con); dataset ds=new dataset(); da.fill(ds,"ali");//ali is ur table name or whatever your table dt=ds.tables["ali"]; display(); }
first_click() //first record button(<<) { n=0; display(); } previous_click() //previous record button(<) { n=n-1; if(n==-1) { n=0; messagebox.show("first record); } else { display(); } } next_click() //next record button(>) { n=n+1 if(n>dt.rows.count-1) } else { display(); } } last_click() //last record button(>>) { n=dt.rows.count-1; display(); }
display() //display function { datarow dr=dt.rows[n]; textbox1.text=dr[0].tostring(); textbox2.text=dr[1].tostring(); }
Happy Coding, BY, R.A.Gladwin
|
| Author: javier 09 Dec 2008 | Member Level: Bronze Points : 2 |
the code has a few errors, like "int n=o;" on the first line, which is an easy fix, just replace the letter "o" with the number "0".
But in the last few lines it refers to "dr" textbox2.text=dr[1].tostring();
dr is not declared anywhere within the code.
I'd like to see this fix as I'm looking forward to understand how the whole thing works and I haven't been able to find a lot of information about this specific topic.
|
| Author: antogladwin 10 Dec 2008 | Member Level: Silver Points : 1 |
hi javier,
i updated the code..thank you for your valuable comments..
by, R.A.Gladwin
|
| Author: antogladwin 10 Dec 2008 | Member Level: Silver Points : 1 |
hi javier,
if you can't understand hereafter also means...im ready to explain, friend.thank you..
//FYI(For your information)
* display() is a function..
* first,last....are buttons
by, R.A.Gladwin
|