随笔 - 34  文章 - 8 评论 - 34 trackbacks - 1
<2008年7月>
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

与我联系

搜索

 

常用链接

留言簿

随笔档案(37)

相册

收藏夹(4)

链接

最新随笔

积分与排名

  • 积分 - 11461
  • 排名 - 2945

最新评论

阅读排行榜

        HttpResponse resp;
        resp = Page.Response;
        resp.Charset = "GB2312";
        resp.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8) + ".xls");//HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8)
        resp.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");//.UTF8
        resp.ContentType = "application/ms-excel";

        System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN", true);
        System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad);
        System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
        gvAsset.DataSource = GridViewBridge("");//这个GridView为在前台定义的控件,有分页
        gvAsset.DataBind();

        GridView gv = new GridView();//实例化一个GridView,无分页,内容同gvAsset  

        gv.DataSource = GridViewBridge("");//数据源
        gv.DataBind();
        gv.RenderControl(oHtmlTextWriter);//gv是定义的不分页Gridview的名称
        Response.Write(oStringWriter.ToString());//Excel导出不支持分页
        Response.End();


    private DataSet GridViewBridge(string strWhere)
    {
        int iAssedId;
        decimal iPriceMin;
        decimal iPriceMax;

        typeModel.cType_Code = dropType.SelectedValue;
        wareModel.cWare_Code = dropWare.SelectedValue;
        if (txtEmpName.Text == "" || txtEmpName.Text == null)
        {
            assetModel.emp_Id = dropEmp.SelectedValue.Trim();
        }
        else
        {
            employeeModel.Emp_Name = txtEmpName.Text;//
        }
        if (dropDepartment.SelectedValue != "")
        {
            Desktop.BLL.Department newdepartment = new Desktop.BLL.Department();
            departmentModel.cChild = newdepartment.GetcChild(dropDepartment.SelectedValue);
        }
        employeeModel.beWorking = dropUserStatus.SelectedValue;
        assetModel.cAsset_Name = txtName.Text;
        assetModel.cAsset_Set = txtSet.Text;
        assetModel.cAsset_From = dropFrom.SelectedItem.Text;
        assetModel.cAsset_Status = dropStatus.SelectedItem.Text;
        if (dtpBeginTime.HasValue == true)
        {
            assetModel.dBuy_Date = dtpBeginTime.Value;
        }
        if (dtpEndTime.HasValue == true)
        {
            assetModel.dReg_Date = dtpEndTime.Value;
        }
        if (txtPriceMin.Text != "")
        {
            if (!decimal.TryParse(txtPriceMin.Text, out iPriceMin))
            {
                MessageBox.Show(this, "请输入数字型最小值");
                txtPriceMin.Focus();
                return null;
            }
            else
            {
                assetModel.iPrice = decimal.Parse(txtPriceMin.Text);
            }
        }
        if (txtPriceMax.Text != "")
        {
            if (!decimal.TryParse(txtPriceMax.Text, out iPriceMax))
            {
                MessageBox.Show(this, "请输入数字型最大值");
                txtPriceMax.Focus();
                return null;
            }
            else
            {
                assetModel.iCurPrice = decimal.Parse(txtPriceMax.Text);
            }
        }
        assetModel.cCheck = dropCheckStatus.SelectedValue;
        assetModel.cBudNo = txtBudNo.Text;
        assetModel.cAccNo = txtAccNo.Text;
        assetModel.cAssetNo = txtAssetNo.Text;
        assetModel.cCheckNo = txtCheckNo.Text;
        assetModel.cAccCorp = txtAccCorp.Text;
        assetModel.cAccCurCorp = txtAccCurCorp.Text;
        assetModel.cSelYes = DropYes.SelectedValue;
        if (txtAssetID.Text != "")
        {
            if (!int.TryParse(txtAssetID.Text, out iAssedId))
            {
                MessageBox.Show(this, "输入系统编号不正确");
                txtAssetID.Focus();
                return null;
            }
            {
                assetModel.iAsset_ID = int.Parse(txtAssetID.Text);
            }
        }

        DataSet ds = asset.GetAssetMain(assetModel, typeModel, wareModel, employeeModel, departmentModel, strWhere);
        return ds;
        // GridViewBind(strWhere);

    }

即数据显示的时候用gvAsset显示,有分页功能,但是Excel导出数据的时候从我们自己定义的gv里面取数据,注意gv是没有分页功能的,可以导出完整数据

posted on 2008-03-24 16:52 星答 阅读(249) 评论(2)  编辑 收藏

FeedBack:
GridViewBridge("");

这代表什么啊?????

  回复  引用    
#2楼 [楼主] 2008-07-25 09:52 星答      
这个代表的是数据源,不知道修正成这样是不是比较容易看懂呢!
  回复  引用  查看    

标题  
姓名  
主页
Email (只有博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2008-07-25 09:54 编辑过