C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Code for next,previous,first,last records...


Posted Date: 17 Jun 2008    Resource Type: Code Snippets    Category: Visual Studio
Author: antogladwinMember Level: Silver    
Rating: Points: 10



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




Responses

Author: javier    09 Dec 2008Member 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 2008Member Level: Silver   Points : 1
hi javier,

i updated the code..thank you for your valuable comments..


by,
R.A.Gladwin


Author: antogladwin    10 Dec 2008Member 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


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Career with microsoft  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Shortcuts for Visual Studio
Previous Resource: Autogeneration numbers...
Return to Discussion Resource Index
Post New Resource
Category: Visual Studio


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use