Click here to Skip to main content
15,879,184 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to bind data to gridview from DataSet with Next Previous Functionality without Repeated hits on DataBase.
Posted
Comments
Priyanka7777 11-Jul-13 1:10am    
What do you mean by Next Previous Functionality without Repeated hits on DataBase.
Can u be a little brief?
Ravi Kumar Shakya 11-Jul-13 2:21am    
I mean to say whenever i click on next, Data shuold be come from dataset only not from database. same with previous click.
I have a dataset with 1000s of records i want to fetch records again n again from dataset not from database.

C#
<asp:gridview id="GridView1" runat="server" xmlns:asp="#unknown" />

protected void Page_Load(object sender, EventArgs e)
{
	if (!Page.IsPostBack)
	{
	string connectionString = "server=SYS2;" + "integrated security=SSPI;" + 	
    	"database=ERPFinAccounting";
	SqlConnection myConnection;
	string str_Account_Select = "SELECT * FROM AccountsTable";
	SqlCommand myCommand;
	DataSet myDataSet;
	myConnection = new SqlConnection(connectionString);
	myConnection.Open();
	myCommand = new SqlCommand(str_Account_Select, myConnection);
	SqlDataAdapter mySQLDataAdapter;
	myDataSet = new DataSet();
	mySQLDataAdapter = new SqlDataAdapter(myCommand);
	mySQLDataAdapter.Fill(myDataSet, "AccountsTable");
	GridView1.DataSource = myDataSet;
	GridView1.DataBind();
	}
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900