Deleting multiple records(rows) from tables using checkboxes

Discussion in 'ASP .Net' started by Patrick.O.Ige, Nov 3, 2005.

  1. 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
     
    Patrick.O.Ige, Nov 3, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sianan
    Replies:
    5
    Views:
    1,230
    S. Justin Gengo
    Oct 27, 2005
  2. Nazar
    Replies:
    0
    Views:
    459
    Nazar
    Aug 14, 2010
  3. Stephen Noronha

    Deleting Multiple Rows

    Stephen Noronha, Feb 19, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    176
    Marshal Antony
    Feb 20, 2004
  4. hbennett

    Problem deleting rows from tables if ID field a GUID

    hbennett, Aug 31, 2005, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    168
    u260044
    Sep 3, 2005
  5. mellie

    Adding multiple records with checkboxes

    mellie, Jul 8, 2004, in forum: ASP General
    Replies:
    1
    Views:
    154
    Bullschmidt
    Jul 8, 2004
Loading...

Share This Page