日期:2014-05-17  浏览次数:20510 次

aspxgridView更新取不到新值
是aspxgridview不是gridview回答的麻烦看清楚,谢谢

我把列转换成了GridViewDataComboBoxColumn这种
HTML code



                        <dx:GridViewDataComboBoxColumn Caption="带班老师" VisibleIndex="3" FieldName="gangerTeacher" >
                            <PropertiesComboBox  ValueType="System.String">
                            </PropertiesComboBox>
                        </dx:GridViewDataComboBoxColumn>



然后绑定了在编辑状态的值
C# code

protected void CoursesDetailsGV_CellEditorInitialize(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewEditorEventArgs e)
    {
        
        if(CoursesDetailsGV.IsEditing)
        {
            if (e.Column.FieldName == "gangerTeacher")
            {
                ASPxComboBox combo = e.Editor as ASPxComboBox;
                combo.ID = "gangerTeacherDdl11";
                combo.TextField = "englishName";
                combo.ValueField = "chineseName";
                DataTable tempdt = Employees.GetEmployeeName(1).Tables[0];
                DataRow tempdr = tempdt.NewRow();
                tempdr["englishName"] = " ";
                tempdr["chineseName"] = " ";
                tempdt.Rows.Add(tempdr);
                combo.DataSource = tempdt;
                combo.DataBind();
            }
}



但是点更新的时候无论如何变都只能取到原来的值,无法获得我改变的值

C# code

    protected void CoursesDetailsGV_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
    {
        int singleCount=Convert.ToInt16(e.NewValues["singleCount"]);
        string singleTime = Convert.ToString(e.NewValues["singleTime"]);
        string gangerTeacher1 = Convert.ToString(e.NewValues["gangerTeacher"]);
        string gangerTeacher2 = Convert.ToString(e.OldValues["gangerTeacher"]);
        string gangerTeacher3 = Convert.ToString(e.Keys["gangerTeacher"]);
        string gangerTeacher = (CoursesDetailsGV.FindControl("gangerTeacherDdl11") as ASPxComboBox).Text;
        string foreignTeacher = (CoursesDetailsGV.FindControl("foreignTeacherDdl") as ASPxComboBox).Text;
        DataTable dt = (DataTable)ViewState["dt"];
        e.Cancel = true;
        CoursesDetailsGV.CancelEdit();

    }


int singleCount=Convert.ToInt16(e.NewValues["singleCount"]);
  string singleTime = Convert.ToString(e.NewValues["singleTime"]);

这两行能取到新值,从第3行开始,都是取不到值,全部是" ";

 string gangerTeacher1 = Convert.ToString(e.NewValues["gangerTeacher"]);
  string gangerTeacher2 = Convert.ToString(e.OldValues["gangerTeacher"]);
  string gangerTeacher3 = Convert.ToString(e.Keys["gangerTeacher"]);

下面这行能取到值,但是是原来的值,取不到修改后的
string gangerTeacher = (CoursesDetailsGV.FindControl("gangerTeacherDdl11") as ASPxComboBox).Text;


这怎么办?

------解决方案--------------------
是不是缓存问题?
------解决方案--------------------
没用过aspxgridview,
友情帮顶