查询方法:
protected void btnSearch_Click(object sender, EventArgs e)
    {
        try
        {
            RS_Person_BLL rpb = new  RS_Person_BLL();
            List<RS_HolidayType> list = rpb.SearchHolidayType(txtHolidayTime.Text,txtHolidayType.Text,txtbank.Text);
            if (list.Count > 0)
            {
                AdjustType_gv.DataSource = list;
                AdjustType_gv.DataBind();
            }
            else
            {
                Tongyong.ShowError(ChkMessage_Panel, ChkMessage_lb, "你输入的搜索条件不正确!");
              
                AdjustType_gv.Visible = false;
          
                ChkMessage_Cancel_Click(sender, e);
            }
        }
        catch (Exception ex)
        {            Tongyong.ShowError(ChkMessage_Panel, ChkMessage_lb, "你输入的搜索条件不正确!");
        }
    }GridView里面的RowDataBound事件:
 protected void AdjustType_gv_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            
           …………            TextBox tempTr = (TextBox)e.Row.Cells[1].FindControl("F_Time");
            DataRowView tempDr = (DataRowView)e.Row.DataItem;无法将类型为“personnelModel.RS_HolidayType”的对象强制转换为类型“System.Data.DataRowView”。
            tempTr.Text = tempDr.Row["H_HolidayTime"].ToString();            TextBox tempTB = (TextBox)e.Row.Cells[1].FindControl("AT_Name");
            DataRowView tempDv = (DataRowView)e.Row.DataItem;
            tempTB.Text = tempDv.Row["H_Bank"].ToString();            TextBox tempTa = (TextBox)e.Row.Cells[1].FindControl("S_Address");
            DataRowView tempDa = (DataRowView)e.Row.DataItem;
            tempTa.Text = tempDa.Row["H_HolidayType"].ToString();
        }
          …………
   }

解决方案 »

  1.   

    因为那行是你的model类型personnelModel.RS_HolidayType  tempDr = (personnelModel.RS_HolidayType)e.Row.DataItem
      

  2.   


    personnelModel.RS_HolidayType dv = (personnelModel.RS_HolidayType)e.Row.DataItem;
    tempTr.Text = dv.Types;
      

  3.   

    类型在转换的时候有问题 用到是三层吗?如果是的话 一般new一下应该可以的吖