日期:2010-10-04  浏览次数:20358 次

因為項目中只能用.net 1.1,所以atlas是用不了了,只能玩玩AjaxProfession.net, 下面是一個查詢的案例。 在頁面上放置一個DataGrid1,各種查詢結果均放入其中,在client端的JS中將SQL語句傳給server端的方法,執行一個查詢,並可以控制雙擊行是否展開一個新的查詢。可將DataGrid1的內容導出到excel中、模擬gmail的Ajax的loading運用

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;
namespace eol
{
    /**//// <summary>
    /// index 的摘要描述。
    /// </summary>
    public class index : System.Web.UI.Page
    {
        protected System.Web.UI.WebControls.TextBox TextBox1;
        protected WebControlLibrary.InputCalendar startTime;
        protected WebControlLibrary.InputCalendar endTime;
        protected WebControlLibrary.InputCalendar pStartTime;
        protected WebControlLibrary.InputCalendar pEndTime;
        protected System.Data.SqlClient.SqlConnection Conn=new SqlConnection();
        protected System.Web.UI.WebControls.TextBox eformsn;
        protected System.Web.UI.WebControls.Label Label1;
        protected System.Web.UI.WebControls.DataGrid DataGrid1=new DataGrid();
        protected System.Web.UI.WebControls.Button Button2;
        protected System.Web.UI.HtmlControls.HtmlInputText applicant;
        public string toExcel;
   
        private void Page_Load(object sender, System.EventArgs e)
        {
            AjaxPro.Utility.RegisterTypeForAjax(typeof(eol.index));
        }

        public DataSet DB(string dataName, string sqlCmd)
        {
            string connStr="server=172.16.0.120;uid=msikdb;pwd=dbmsik;database="+dataName;
            Conn.ConnectionString=connStr;
            try
            {
                Conn.Open();
            }
            catch(Exception ex)
            {
                Conn.Close();
                Response.Write(ex.Message);
            }
            SqlCommand cmd=new SqlCommand(sqlCmd, Conn);
            SqlDataAdapter da=new SqlDataAdapter();
            da.SelectCommand=cmd;
            DataSet ds = new DataSet();
 &nb