0

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....

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by shiva07
0

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;

0

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

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.