• gridview 添加进度条


     

    1.ChartHandler.ashx

    <%@ WebHandler Language="C#" Class="ChartHandlerTest" %>

    using System;
    using System.Web;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Drawing.Imaging;

    public class ChartHandlerTest : IHttpHandler {
        
        public void ProcessRequest (HttpContext context) {
            decimal ounitprice = decimal.Parse(context.Request.QueryString["outprice"]);
            decimal punitprice = decimal.Parse(context.Request.QueryString["inprice"]);

            using (Bitmap bitmap = new Bitmap(10040))
            {
                using (Graphics graphics = Graphics.FromImage(bitmap))
                {
                    graphics.SmoothingMode = SmoothingMode.AntiAlias;
                    graphics.Clear(Color.White);
                    Rectangle rect = new Rectangle(0010040);
                    graphics.DrawRectangle(Pens.Black, rect);
                    int width = Convert.ToInt32(ounitprice * 100 / punitprice);
                    Rectangle fillRect = new Rectangle(00, width, 40);
                    graphics.FillRectangle(Brushes.Red, fillRect);
                    context.Response.ContentType = "text/gif";
                    context.Response.Clear();
                    context.Response.BufferOutput = true;
                    bitmap.Save(context.Response.OutputStream, ImageFormat.Gif);
                }
            } 
        }
     
        public bool IsReusable {
            get {
                return false;
            }
        }
    } 


    2.test.aspx 

    <body>
        <form id="form1" runat="server">
        <div>
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
                <Columns>
                    <asp:BoundField DataField="pjid" HeaderText="pjid" SortExpression="pjid" />
                    <asp:BoundField DataField="paid" HeaderText="paid" InsertVisible="False"
                        ReadOnly="True" SortExpression="paid" />
                    <asp:BoundField DataField="outprice" HeaderText="outprice" SortExpression="outprice" />
                    <asp:BoundField DataField="inprice" HeaderText="inprice" SortExpression="inprice" />
                    <asp:TemplateField HeaderText="百分比">
                        <ItemTemplate>
                            <img src='<%# "ChartHandlerTest.ashx?outprice=" + Eval("outprice") + "&inprice=" + Eval("inprice")%>' alt='<%# "完成情况:" + (Convert.ToDecimal(Eval("outprice")) * 100 / Convert.ToDecimal(Eval("inprice"))).ToString("F2") + "%"  %>'/>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <br />
            <br />
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConnectionString="Data Source=10.10.0.33;Initial Catalog=aeadmin;User ID=snow;Password=abc12" 
                ProviderName="System.Data.SqlClient" 
                SelectCommand=" select pjid,paid,outprice,inprice from testWW ">
            </asp:SqlDataSource>

        </div>    </form></body> 


  • 相关阅读:
    PHP木马免杀的一些总结
    regsvr32 bypass windows defender 新思路
    要点4:C的文件操作
    【Go语言探险】线上奇怪日志问题的排查
    Eclipse部署虚拟项目目录
    osgEarth使用笔记4——加载矢量数据
    three.js中的矩阵计算
    GDAL数据集写入空间坐标参考
    matlab 基础
    nginx 配置文件解读
  • 原文地址:https://www.cnblogs.com/Snowfun/p/3096525.html
Copyright © 2020-2023  润新知