Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
krishnet
Starting Member
29 Posts |
Posted - 2007-05-16 : 06:15:44
|
Hello frdz, I want to delete the multiple items from the gridview with the help of the checkbox.I have the linkbutton for the delete in the gridview which performs the delete operation getting data with the sqldatasource from sqlserver 2005This is the asp.net C# 2005 code which i have done for the above: private void DeleteSelectedCompany() { string id = ""; bool chkBox = false; foreach (GridViewRow row in CompanyGridView.Rows) { CheckBox deleteChkBxItem = (CheckBox)row.FindControl("check1"); if (deleteChkBxItem.Checked) { chkBox = true; string companyid = CompanyGridView.DataKeys[row.RowIndex].Value.ToString(); DELETE from company "WHERE id = '" + id + "'" ; } } }Pls can anyone rectify what's wrong in the coding.Is the delete query written for deleting the multiple items is correct ?It is giving me the error over there. I want to also know where to call this function and how ??Thanxs in advance for ur help if provided. |
|
jsmith8858
Dr. Cross Join
7423 Posts |
|
krishnet
Starting Member
29 Posts |
Posted - 2007-05-16 : 10:44:31
|
Thanxs for ur suggestion regarding the connection to database i m retrieving the data thru sqldatasource which does not requires any sqlcommand i think my dear frd.I m not using objectdatasource.If at all i m wrong then i will see as u said.But,tell me that sqldatasource needs any connection it requires only the connectionstring to connect to database as i know.So,if i m not wrong then pls rectify and tell what's missing and how to write the query of delete using sqldatasource.The simple delete query is running with the help of sqldatasource but can't delete the multiple items with the help of the checkbox. |
|
|
|
|
|