0
 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?

2
Contributors
1
Reply
19
Views
3 Years
Discussion Span
Last Post by lolafuertes
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.