Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Deleting multiple records(rows) from tables using checkboxes

Reply
Thread Tools

Deleting multiple records(rows) from tables using checkboxes

 
 
Patrick.O.Ige
Guest
Posts: n/a
 
      11-03-2005
I have a datagrid with checkboxes..
When a user clicks one check box and clicks the delete button it deletes
that ROw.
There another situation when a user clicks multiple rows so i had to loop
throug the rows like so:-
foreach (DataGridItem i in DataGrid1.Items)
{
CheckBox deleteChkBxItem = (CheckBox) i.FindControl ("DeleteRow");
if (deleteChkBxItem.Checked)
{
BxsChkd = true;
// Concatenate DataGrid item with comma for SQL Delete
dgIDs += ((Label) i.FindControl ("postID")).Text.ToString() + ",";
}
}
The postid is integer and it has to be Concatenate with comma to delete
multiple rows..
If i do deleteSQL = "DELETE from prodcuts WHERE postID IN (" +
dgIDs.Substring (0, dgIDs.LastIndexOf (",")) + ")";
using inline code it works
But if i move it to a stored procedure and select multiple rows to delete it
gives me error
Error converting data type nvarchar to int.!!!
And i guess converting string to integer would hard since it has a comma in
it.
I tried
string p = dgIDs.Substring (0, dgIDs.LastIndexOf (","));
h = Int32.Parse(p);//No sense here i know
Any way around this



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help: Using Multiple Checkboxes in a Checkboxlist to filter results in a gridview in ASP.NET 2.0 joebob8000 ASP .Net 0 12-04-2006 07:54 PM
bind multiple data tables from sql queries to multiple datacontainers? Daves ASP .Net 1 01-06-2006 04:17 PM
Help: Using Multiple Checkboxes or Checkboxlist to filter results in a gridview in ASP.NET 2.0 / VS2005 Faybert@gmail.com ASP .Net 0 12-29-2005 11:43 PM
adding values to tables using checkboxes teh.redworm@gmail.com ASP .Net 0 12-20-2005 08:13 AM
Deleting row generated from multiple tables Motley Drew ASP .Net Datagrid Control 0 02-03-2004 05:40 PM



Advertisments