hello everyone

i try to explain my problem by this following example

i have a gridview binded to a table with columns as(name,rollno,status, and last column of the gridview contains a checkbox)

now the problem is i want when i check the checkbox of a particular row...then the status column value on that particular row to be changed/updated....

i m doing like dis

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {


        SqlCommand cmd = new SqlCommand();
        cmd.Connection = conn;

        cmd.CommandText = " update dummytable set status =@status";
        cmd.Parameters.Add("@status", SqlDbType.NVarChar, 50).Value = "dispproved";

        cmd.ExecuteNonQuery();
        cmd.Dispose();
        GridView1.DataBind();
        conn.Close();

    }

now wat is happening ....it updates for all the rows...not for the particular row...pls help thank u....

no replies!!hmm

Use WHERE clause.

UPDATE TableName SET Column1=Value1 WHERE Column2=Value2

where clause was helpful..
also to access a particular column value ...we can us

gridview row= gridview1.selectedrow;
label1.text=row.Cells[index of the column].text;

#
cmd.Parameters.Add("@status", SqlDbType.NVarChar, 50).Value = "dispproved";
#
use this code

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.