Harsh Jani

Harsh Jani

  • NA
  • 34
  • 53.7k

Unable to bind DataGridView

Jan 27 2015 12:33 AM
Hi,
 
I am creating a Windows Application. I am unable to Bind DataGridView. I am using the following code to bind DataGrid. The code does not show any error but every time I try to bind DataGrid, it does not  display any value. 
 
private void BindGridView()
{
      List<OrganizationType> ListAllOrganizationType = obj_OrganizationType.SelectAll();
      string OrganizationNameSearch = cmb_OrganizationTypeName.Text.ToString().ToLower();
      var ListOrganzaitionType = (List<OrganizationType>)(from OrgType in ListAllOrganizationType where (OrganizationNameSearch == string.Empty       ? true : (OrgType.TypeName.ToLower().Contains(OrganizationNameSearch))) select OrgType).ToList();
 
      if (ListOrganzaitionType.Count > 0)
      {
               gv_OrganizationType.DataSource = new List<OrganizationType>(ListOrganzaitionType);
      }
      else
      {
               MessageBox.Show("No Records Found", "Alert");
      }
}
 
Kindly let me know what is the error in the above code.
 
Thank you. 
 

Answers (5)