Monday, March 26, 2012

Maually update gridview

I want to write the results of a checkbox to my database, but I am stuck on the syntax?

Here's what I have so far, could somebody pleae help., my aim is to not show a line when checkbox ticked, not to actually delete the record from the database

Hi, The problem that I have now is that yes I want to delete from gridview, but I still want the old record to be in database ,not deleted. Does anybody know how I can evaluate my checkbox, and update to the database the results of the checkbox,I am not sure of the update syntax?

string strsql ="update * from jobs order by ID asc";

SqlConnection conn =newSqlConnection(ConnectionString);

SqlDataAdapter ad =newSqlDataAdapter(strsql, conn);

DataSet ds =newDataSet();ad.Fill(ds,"TASKS");

GridView1.DataSource = ds;

GridView1.DataBind();

got stuck here, basically I cant work out how to evauate the results of a checkbox, and write back to the database, can anybody help?

The update syntax should be

Update JOBS Set Column_Name = Value where ID= ID_Value

COLUMN_NAME is the Name of Column you want to update

Value is the new value which you want to go in database

ID is the Column for which Id user Selected

ID_Value is the value of ID

Let me know if this helped you.

No comments:

Post a Comment