设置首页  |   加入收藏  |  联系我们   
您的位置: 主页>网站设计>AJAX>正文
Ajax实现DataGrid/DataList动态ToolTip
文章来源:  编辑:  发布时间:2007-12-14

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; // 文件大小
        string Type = FileUpload1.PostedFile.ContentType; // 文件类型
        ImageStream = FileUpload1.PostedFile.InputStream;
        byte[] Content = new byte[Size];
        int Status = ImageStream.Read(Content, 0, Size);

        SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);

 
Tags:动态 实现 ID string SqlConnection if new td 文件 conn

Google
 
上一篇: Ajax实现在textbox中输入内容,动态从数据库中模糊查询显示到下拉框中   下一篇: AJAX支持的自动填充表单
【返回顶部】 【打印】 【大】 【中】 【小】 【关闭】

 我来说两句
用户名: 新注册) 密码: 匿名评论 [论坛讨论]
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 相关文章
 热门文章

 
版权所有  2005-2006  Linux集中营  闽ICP备07500055号