Click here to Skip to main content
14,639,719 members
Rate this:
Please Sign up or sign in to vote.
See more:

I have a datatable dtFillBusinessFields. I need to remove a row from that datatable on the basis of a condition.

I tried with the code

private void funRemoveData()
  int vIntCritraIdId = -1;
  foreach (DataGridItem VselectedFile in grdShowBusinessRules.Items)
    if (((HtmlInputCheckBox)VselectedFile.FindControl("chkSelect")).Checked)
      dtFillBusinessFields = (DataTable)Session["BUSINESSRILE"];
      vIntCritraIdId = Convert.ToInt32(VselectedFile.Cells[0].Text);
      dtFillBusinessFields.Rows.Remove(dtFillBusinessFields.Rows.Find("intID= " + vIntCritraIdId + "")); 
      grdShowBusinessRules.DataSource = dtFillBusinessFields;
      Session["BUSINESSRILE"] = dtFillBusinessFields;

We get the selected criteria ID in the variable "vIntCritraIdId" and "intID" is the correspondi column name in the data tabel. I need to remove the data coresponding to the condition "intID = vIntCritraIdId"
Updated 5-Nov-10 21:38pm

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Have a look at the link below. You can find some good information in these code examples to get the above code working, like the method DetermineSelection.[^]

Good luck!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100