Code for next,previous,first,last records...
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
hi javier,
i updated the code..thank you for your valuable comments..
by,
R.A.Gladwin