zoukankan      html  css  js  c++  java
  • 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> 


  • 相关阅读:
    -1%256的值是多少?
    Glut,程序的基本架构
    剑指offer:数值的整数次方
    剑指offer:二进制中1的个数
    剑指offer:斐波那契数列的应用
    剑指offer:斐波那契数列
    剑指offer:旋转数组中的最小数字
    弱智的grub消除法
    POJ 3126 Prime Path
    HDU 1426 Sudoku Killer
  • 原文地址:https://www.cnblogs.com/Snowfun/p/3096525.html
Copyright © 2011-2022 走看看