Deleting multiple records(rows) from tables using checkboxes

P

Patrick.O.Ige

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top