【问题标题】:Devexpress gridview problemDevexpress 网格视图问题
【发布时间】:2011-01-23 14:01:11
【问题描述】:

当我在绑定 gridview 之前访问数据库时 网格视图不再绑定 这里有一些代码:

    void Page_Load(object sender, EventArgs e)
{ 
    if (!IsPostBack)
    {
        date.Date = DateTime.Now;
        string mode = Request.Params["mode"].ToString().ToLowerInvariant();
        lblPatientName.Text= Session["PatientName"].ToString();
        switch (mode)
        {
            case "new":
                {
                    Page.Title = "Add New Patient Visit";

                    Session["visitID"] = System.Guid.NewGuid();

                    //get basic data (countrycode,cityCode,districtCode,areaCode) from patientdata table
                    SqlParameter pra = new SqlParameter("@Patientid", Session["PatientID"].ToString());
                    SqlDataReader dr = SqlHelper.ExecuteReader(ConfigurationManager.ConnectionStrings["NetCareConnectionString"].ConnectionString,
                           "PatientPrescriptionInsertPrepare", pra);

                    if (dr.Read())
                    {
                        SqlParameter[] prm = new SqlParameter[7];

                        prm[0] = new SqlParameter("@visitID", Session["visitID"].ToString());
                        prm[1] = new SqlParameter("@Patientid", Session["PatientID"].ToString());
                        prm[2] = new SqlParameter("@Specialization", Session["special"].ToString());
                        prm[3] = new SqlParameter("@countrycode", dr["CountryCode"].ToString());
                        prm[4] = new SqlParameter("@cityCode", dr["CityCode"].ToString());
                        prm[5] = new SqlParameter("@districtCode", dr["DistrictCode"].ToString());
                        prm[6] = new SqlParameter("@areaCode", dr["AreaCode"].ToString());
                        SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "PreparePrescrption", prm);
                    }

                }
                break;
        }

    }
}  

当我使用事件绑定网格时,当我删除上面的代码时,一切都运行良好:

 protected void btnAdd_Click(object sender, EventArgs e)
{

    SqlParameter [] prm = new SqlParameter[3];
    prm[0] = new SqlParameter("@visitID", Session["visitID"].ToString());
    prm[1] = new SqlParameter("@Patientid", Session["PatientID"].ToString());
    prm[2] = new SqlParameter("@examinationcode", Session["Examinationcode"].ToString());
    SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "PatientExaminations_insert", prm);
    gvParientInvs.DataBind();
}

【问题讨论】:

    标签: data-binding gridview devexpress sqlhelper


    【解决方案1】:

    您应该调用 ASPxGridView 的 DataBind 方法来强制网格从底层 DataSource 获取数据。此外,如果您在运行时设置 ASPxGridView 的 DataSource,您应该在对服务器的每个请求都执行此操作,如

    中所述

    Why might paging (sorting, grouping, filtering) not work in the ASPxGridView?

    文章。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-10
      • 1970-01-01
      • 1970-01-01
      • 2017-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多