Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.

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;
      grdShowBusinessRules.DataBind();
      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"
Posted
Updated 5-Nov-10 21:38pm
v2

1 solution

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.

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datagrid.items.aspx[^]

Good luck!
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900