protected void Page_Load(object sender, EventArgs e)
    {

        if (!Page.IsPostBack)
        {


            sqlcon.Open();
            sqlcmd = new SqlCommand("select * from category" , sqlcon);

            da = new SqlDataAdapter(sqlcmd);
            da.Fill(dt);

            if (dt.Rows.Count > 0)
            {
                        TextBox4.Text = dt.Rows[0][7].ToString();
                        TextBox2.Text = dt.Rows[0][8].ToString();
                        TextBox3.Text = dt.Rows[0][9].ToString();

          }
            sqlcon.Close();
        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {

        SqlCommand cmd = new SqlCommand();
        sqlcmd = new SqlCommand("update category set invcategorycode='" + TextBox2.Text + "',invcategorydesc='" + TextBox3.Text + "' where invcategorydescar='", sqlcon);
        sqlcmd.Parameters.AddWithValue("@invcategorycode", TextBox4.Text);
        sqlcmd.Parameters.AddWithValue("@invcategorydesc", TextBox2.Text);
        sqlcmd.Parameters.AddWithValue("@invcategorydescar", TextBox3.Text);
        sqlcon.Open();
        sqlcmd = new SqlCommand();
        sqlcmd.ExecuteNonQuery();
        int result= cmd.ExecuteNonQuery();
        if (result == 1);
        sqlcon.Close();
    }
    protected void LinkButton11_Click(object sender, EventArgs e)
    {
        Response.Redirect("Category.aspx");
    }
}  

in this code only information of the first row is read to all the rows
and am getting an error in ExecuteNonQuery();
how can i get each edit next to a row to read its information?

Wy the line 34 sentence? this will clear all the preceding content in the command and create an empty one, so executing an empty command will fail.

Also, you are using the Parameters of the sqlcommand, but you do not defined any in the sql sentence.
Please visit this page http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.parameters.aspx for examples on how to define and use the Parameters.

Hope this helps

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.