Check Box In A datagrid

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sumithsumith
    New Member
    • Mar 2007
    • 13

    Check Box In A datagrid

    hi friends,
    i need code for deleting a particular row from a datagrid when i select the particular checkbox in the same datagrid.
    Thanking You..
  • sani723
    New Member
    • Feb 2007
    • 117

    #2
    you can find here

    Check This

    Or this

    Click Here

    Comment

    • ashasprabhu
      New Member
      • Jan 2007
      • 52

      #3
      hi,
      check this example this will surely help u
      http://aspalliance.com/articleViewer.a spx?aId=427&pId =-1
      bye
      all the best

      Comment

      • NithyaJai
        New Member
        • Mar 2007
        • 18

        #4
        hai,
        i think this vl b helpful..
        write this code in ur delete button......
        try it out..

        private void btnDelete_Click (object sender, System.EventArg s e)
        {
        int cId;
        string id;
        foreach (DataGridItem dg in datagrid.Items)
        {
        CheckBox deleteChkBxItem = (CheckBox)dg.Ce lls[0].FindControl("c hkSelect");
        if (deleteChkBxIte m.Checked == true)
        {
        id= (((Label)dg.Cel ls[1].FindControl("I D")).Text);
        cId=Convert.ToI nt32(id.ToStrin g());
        SqlConnection conn;
        conn =new SqlConnection(" Data Source=xyz;Init ial catalog=dbname; user id=sa");
        conn.Open();
        SqlCommand mycom=new SqlCommand("del ete from table where Id=@ID ",conn);
        mycom.CommandTy pe=CommandType. StoredProcedure ;
        SqlParameter[] sqlparam=new SqlParameter[1];
        sqlparam[0]=new SqlParameter("@ ID",System.Data .SqlDbType.Int, 4);
        sqlparam[0].Value=cId;
        mycom.Parameter s.Add(sqlparam[0]);
        mycom.ExecuteNo nQuery();
        conn.Close();
        }
        }
        }

        Comment

        Working...