本帖最后由 CrazySolo1986 于 2010-11-12 11:52:35 编辑

解决方案 »

  1.   

    DataGridView.DataSource=你查询到的数据
      

  2.   

      List<Bll.Patient> patients = Bll.Patient.GetPatientInHospital(BedCode, "", Context.Current.User.DP_ID, txtPa_Id.Text.Trim());
                
                dgvPatient.Rows.Clear();
                foreach(Bll.Patient patient in patients)
                {
                    dgvPatient.Rows.Add();
                    int c = dgvPatient.Rows.Count - 1;
                    DataGridViewRow row = dgvPatient.Rows[c];
                    row.Cells["pId"].Value = patient.Id;
                    row.Cells["pName"].Value =patient.BedCode+" "+ patient.Name;
                    row.Cells["pPa_Id"].Value = patient.PA_ID;
                  //  row.Cells["pBedCode"].Value = patient.BedCode;
                    row.Cells["pBirthday"].Value = patient.Birthday;
      

  3.   

       if (dt.Rows.Count > 0)
                {
                    dgvType.Rows.Clear();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        
                        dgvType.Rows.Add();
                        int num = dgvType.Rows.Count - 1;
                        DataGridViewRow row = dgvType.Rows[num];
                        DataRow dr = dt.Rows[i];
                        row.Cells["tId"].Value = dr["ID"].ToString();
                        row.Cells["tcode"].Value = dr["DName"].ToString();
                        row.Cells["tCName"].Value = dr["ChineseName"].ToString();
                        row.Cells["tType"].Value = dr["TypeName"].ToString() == "Task" ? "医护任务" : "协同消息";
                        row.Cells["tAreaID"].Value = dr["DAreaID"].ToString();
                        if (dr["Disabled"].ToString() != "")
                        {
                            row.Cells["tisf"].Value = (bool)dr["Disabled"] ? "启用" : "禁用";
                            row.Cells["tissend"].Value = (bool)dr["IsAllowSended"] ? "是" : "否";
                            row.Cells["trea"].Value = dr["Node"].ToString();
                        }
      

  4.   

    一种是实体 一种是datatable
      

  5.   

    直接绑定dataset,觉得这种方法还是可取的
      

  6.   

    把数据填充到datagridview:dataset.表名.clear();
    sqldataadapter.fill(dataset.表名);
    datagridview.datasource=dataset.表名;
    进行数据更新:你可以直接在datagridview进行修改操作,并结果更新到数据源
    sqldataadapter.update(dataset.表名);用到sqldataadapter的fill,update这个两个方法
      

  7.   

    我还在考虑到底是用LISTVIEW好还是DATAGRIDVIEW好呢纠结~~~