首页 | 源码下载 | 网站模板 | 网页特效 | 广告代码 | 网页素材 | 字体下载 | 书库 | 站长工具
会员投稿 投稿指南 RSS订阅
当前位置:主页>网络编程>ajax教程>资讯:Ajax实现DataGrid/DataList动态ToolTip

Ajax实现DataGrid/DataList动态ToolTip

www.jz123.cn  2008-09-21   来源:   中国建站    袁袁整理    我要投递新闻

1.建立一aspx页面,html代码2.cs代码


using System.Data.SqlClient;
using System.IO;
protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            BindData();
           
        }
        if (ID != "")
        {
            GetDescriptionByID(ID);
        }
       
    }

    property#region property
    private string ID
    {
        get
        {
            if (Request["ID"] != null && Request["ID"].ToString() != "")
            {
                return Request["ID"];
            }
            else
            {
                return "";
            }
        }
    }
    #endregion

    GetDescriptionByID#region GetDescriptionByID
    private void GetDescriptionByID(string ID)
    {
        string connStr = ConfigurationSettings.AppSettings["ConnectionString"];
        SqlConnection conn = new SqlConnection(connStr);
        string sql = "select * from testimage where userid='" + ID + "'";
        SqlCommand cmd = new SqlCommand(sql, conn);
        conn.Open();
        SqlDataReader dr = cmd.ExecuteReader();

        string s = @"<table cellspacing='0' cellpadding='4' width='300' height='200' border='0' id='GridView1' style='color:#333333;border-collapse:collapse;'>";
        if(dr.Read())
        {
            s += "<tr style='color:#333333;background-color:#FFFBD6;'>";
            s += "<td width='50'>名称:</td>";
            s += "<td>" + dr["UserName"] + "</td>";
            s += "</tr>";
            s += "<tr style='color:#333333;background-color:White;'>";
            s += "<td scope='col'>描述:</td>";
            s += "<td>" + dr["Description"] + "</td>";
            s += "</tr>";
        }
        s += "</table>";
        dr.Close();
        conn.Close();
        this.Response.Write(s);
        this.Response.End();
    }
    #endregion

    save image#region save image
    protected void Button2_Click(object sender, EventArgs e)
    {
        Stream ImageStream;
        string Path = FileUpload1.PostedFile.FileName;// 文件名称
        int Size = FileUpload1.PostedFile.ContentLength; // 文件大小

上一篇:Ajax简单示例之改变下拉框动态生成表格 下一篇:Ajax实现在textbox中输入内容,动态从数据库中模糊查询显示到下拉框中

评论总数:2 [ 查看全部 ] 网友评论