string code;
            code = textBox.Text;
            r = dp.Tables[Tablename].Rows.Find(code);
            r.Delete();
            db.Update(dp);

r is datarow.
dp is dataset
db is dataAdapter.

You can find the row that u want to delete by entering a column name.
And then this code would delete that row and would also update your table.

#Aspx Page
#-----------
# This is the template filed of the grid view... Grid view template column for the check boxk
<asp:TemplateField HeaderText="Select">
                                            <ItemTemplate>
                                                <asp:CheckBox ID="chkSelect" runat="server" />
                                            </ItemTemplate>
                                        </asp:TemplateField>

# button
<asp:Button ID="btnDelete" runat="server" Text="Delete" Width="10%" OnClick="btnDelete_Click1" />


#Code
#------------
 
protected void btnDelete_Click1(object sender, EventArgs e)
    {
        
        foreach(GridViewRow row in GridView1.Rows)
        {

            CheckBox cb = (CheckBox)row.FindControl("chkSelect");

            if (cb.Checked && cb != null)
            {

                int ID_No= Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value);
                		
		# Make query for Deleting Row form Category ID  example : delete * from table where id=ID_No               
		
               
            }
        }
		
	# Rebind Grid View Here.
       

    }

Regards,
jay

Edited 5 Years Ago by Ezzaral: Snipped url. Please restrict personal links to your user signature.

This article has been dead for over six months. Start a new discussion instead.