i have to set status as accept,reject for customer,while registering status while be pending. i need ,if condition for this, which row is selected then corressponding event should change in database as accept or reject
protected void Button2_Click(object sender, EventArgs e) {
SqlCommand cmd = new SqlCommand("select * from Testing", OIMS_01);
SqlDataAdapter ad = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
ad.Fill(ds);
if (GridView1.SelectedRow != null)
{
ds.Tables(0).Rows(0).Item(0) = GridView1.SelectedRow.Cells(1).Text;
ds.Tables(0).Rows(0).Item(1) = GridView1.SelectedRow.Cells(2).Text;
ds.Tables(0).Rows(0).Item(2) = "Accept";
}
else
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please select a row.')", true);
}
ad.Update(ds);
}
Vishal GilbilePosted Apr 2, 2013, 2:27 AM
You could get the index no of the gridview row which is being currently selected by using the following line of code.
int index = ((GridViewRow)((Button)sender).NamingContainer).RowIndex;
then finally after getting the index no of the row you could easily change the data in the database to accept, reject or pending as per your scenario by firing update query.
Hope that solves your problem.
With Regards,
Vishal Gilbile.