hello i have 5 text boxes and labels and database in sql server so just need coding for the next and the previous button any one can help please thanks

You have to use DataBinding. Get the data you want to show in textBoxes in the dataTable, then set data binding for each textBox and use "CurrencyManager".

Here is a great example, its all there.
Take your time to study all whats there on this website.

cya

You have to use DataBinding. Get the data you want to show in textBoxes in the dataTable, then set data binding for each textBox and use "CurrencyManager".

Here is a great example, its all there.
Take your time to study all whats there on this website.

cya

ok thanks a lot i'l study this and if have any problem i'l let you know thanks

Ok.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;






public partial class _Default : System.Web.UI.Page
{
    

    protected void Page_Load(object sender, EventArgs e)
    {

        try
        {


            SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConn"].ToString());

            SqlCommand cmd = new SqlCommand("SELECT * FROM employee", cn);

          
            cn.Open();
            SqlDataReader rdr = cmd.ExecuteReader();
            if (rdr.Read())
            {
                txtName.Text = rdr.GetValue(0).ToString();
                txtcompany.Text = rdr.GetValue(1).ToString();
                txtAddress.Text = rdr.GetValue(2).ToString();
                txtSalary.Text = rdr.GetValue(3).ToString();
                txtPhone.Text = rdr.GetValue(4).ToString();
            }

            cn.Close();

            /**while (rdr.Read())
            {
                Response.Write("Name = " + rdr[0].ToString() + "<BR>"); //read a value
            }*/

        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());

        }




    }


    protected void cmdSubmit_Click(object sender, EventArgs e)
    {




        string strName;
        strName = txtName.Text;
        string strcompany;
        strcompany = txtcompany.Text;
        string strAddress;
        strAddress = txtAddress.Text;
        string strSalary;
        strSalary = txtSalary.Text;
        string strPhone;
        strPhone = txtPhone.Text;

        try
        {


            SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConn"].ToString());

            cn.Open();

            SqlCommand cmd = new SqlCommand();

            cmd.Connection = cn;
            cmd.CommandType = System.Data.CommandType.Text;
            cmd.CommandText =
"INSERT INTO employee(name,company,address,Salary,Phone)values(@name,@company,@address,@Salary,@Phone)";


            //                  insert into Employee(name,Company)values('gaurav','abc')

            cmd.Parameters.AddWithValue("@Name", strName);
            cmd.Parameters.AddWithValue("@company", strcompany);
            cmd.Parameters.AddWithValue("@address", strAddress);

            cmd.Parameters.AddWithValue("@Salary", strSalary);
            cmd.Parameters.AddWithValue("@Phone", strPhone);

            int intRowsAffected = cmd.ExecuteNonQuery();
            Response.Write(" Number of rows affected = " + intRowsAffected);

        }

        catch (Exception ex)
        {
            Response.Write(ex.ToString());


        }

    }
    /**SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConn"].ToString());
    SqlCommand comm1 = new SqlCommand();
    cn.Open();
    SqlDataReader Employee = comm1.ExecuteReader();
    if (Employee.Read())
    {
        txtName.Text = Employee.GetValue(0).ToString();
    }

    cn.Close();
}*/








    protected void btnDelete_Click(object sender, EventArgs e)
    {
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConn"].ToString());
        conn.Open();
        SqlCommand cmd = new SqlCommand("DELETE FROM employee WHERE Name='" +txtName.Text+ "'", conn);
        cmd.ExecuteNonQuery();
       
        

        txtName.Text = ""; 
        txtcompany.Text = ""; 
        txtAddress.Text = ""; 
        txtSalary.Text = "";
        txtPhone.Text = "";
        conn.Close();

        
          




        }

    
    protected void btnNext_Click(object sender, EventArgs e)
    {
    

        }

this is the complete coding am using upto this everything working just tell me acc to my code what i have to do for NEXT and PREVIOUS BUTTIN coding thanks..

Hmmm, you didn`t study that link at all. I can see that from your code.
I cannot do all the code instead of you.
Please as I told you, read all whats there on that website.

Some way points: you have to get the data from databse into DATATABLE (not directly into textboxes).
Use connection and dataAdapter classes to fill dataTable, the follow the steps from that website (you have to use controls databinding, and CurrencyManager class on those two buttons forward and backward).

Hmmm, you didn`t study that link at all. I can see that from your code.
I cannot do all the code instead of you.
Please as I told you, read all whats there on that website.

Some way points: you have to get the data from databse into DATATABLE (not directly into textboxes).
Use connection and dataAdapter classes to fill dataTable, the follow the steps from that website (you have to use controls databinding, and CurrencyManager class on those two buttons forward and backward).

no actually this coding i have before you give me that link so just sharing with you

no actually this coding i have before you give me that link so just sharing with you[/QUh

hey can you tell me what should be the coding for next and previous button acc to my coding . please help me if you can thanks

// Position to prev Record in Customer
        private void btnPrev_Click(object sender, System.EventArgs e)
        {
            if (this.BindingContext[dsView,"Customers"].Position > 0)
            {
                this.BindingContext[dsView,"Customers"].Position--;
            }
        }

        // Position to next Record in Customer
        private void btnNext_Click(object sender, System.EventArgs e)
        {
            CurrencyManager cm = (CurrencyManager)this.BindingContext[dsView,"Customers"];
            if (cm.Position < cm.Count - 1)
            {
                cm.Position++;
            }
        }
// Position to prev Record in Customer
        private void btnPrev_Click(object sender, System.EventArgs e)
        {
            if (this.BindingContext[dsView,"Customers"].Position > 0)
            {
                this.BindingContext[dsView,"Customers"].Position--;
            }
        }

        // Position to next Record in Customer
        private void btnNext_Click(object sender, System.EventArgs e)
        {
            CurrencyManager cm = (CurrencyManager)this.BindingContext[dsView,"Customers"];
            if (cm.Position < cm.Count - 1)
            {
                cm.Position++;
            }
        }

yes this thing i know but where i can define current manager and binding text?

As I see from you code, you are doing .NET application (web application).
So CurrencyManager is out of question. It is only available in win forms. Win forms and Asp.net applications are two completel different things.
Iam not very familiar with asp.net programming (yet), so I cannot help you out here. Sorry. But you can take a look at here, or ask a question to some Asp.NET forum.
I hope you manage to work it out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.