动态生成.aspx和.aspx.cs页面(有添加删除等操作)
-------
说说技术点,或者提高源代码。

解决方案 »

  1.   

    .aspx.cs页面要经过动态编译才行。
      

  2.   

    lz真强,我暂时不知道
    如果能够动态生成RMB就好了。
      

  3.   

    要实现楼主的动态生成ASPx文件有Gridview删除添加等操作这个是可行呢?
    到如果要动态生成的话就不能采用ASPX+.CS文件方式了。
    就只能使用ASPX文件,那么CS文件里面的代码就只能以为<script runat=server></script>
    的方式插入到ASPX文件里面了。这样就是实现楼主的想法了
    更多资料:http://www.34v.com
      

  4.   

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;using Tool;
    using Manager;
    using Entity;public partial class Web_ConmanShipList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {        if (!IsPostBack)
            {
                try
                {
                    this.Page.Title = "青岛诚信网-天天315,诚信论坛,法律维权,在线投诉,骗术解密,失信曝光,供求信息,加盟代理,加工合作,求职招聘,商家活动,打折优惠,电子明信片,优惠卷";
                    this.BindDropDownListType();
                    this.BindRadioButtonList();
                    this.BindPageIndex(1);
                }
                catch (Exception ex)
                {
                    this.lblMessage.Text = ex.Message;
                }
            }
            this.btnDelete.Attributes.Add("onClick", "return confirm('确定要删除该记录?');");
        }    /// <summary>
        /// 实现查询功能和模糊查询    /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSelect_Click(object sender, EventArgs e)
        {
            try
            {            this.BindPageIndex(1);
            }
            catch(Exception ex)
            {
                this.lblMessage.Text = ex.Message;
            }    }    /// <summary>
        /// 实现添加功能
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            Response.Redirect("ConmanShipAdd.aspx");
        }    /// <summary>
        /// 实现修改更新功能
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                for (int i = 0; i < this.gvConmanShip.Rows.Count; i++)
                {
                    if (((CheckBox)this.gvConmanShip.Rows[i].Cells[0].Controls[1]).Checked == true)
                    {
                        int ConmanShipID = UtilTool.ToSafeInt32(this.gvConmanShip.DataKeys[i].Value);
                        Response.Redirect("ConmanShipAdd.aspx?ConmanShipID=" + ConmanShipID);
                    }
                }
            }
            catch (Exception ex)
            {
                this.lblMessage.Text = ex.Message;
            }
        }    /// <summary>
        /// 实现删除功能
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                for (int i = 0; i < this.gvConmanShip.Rows.Count; i++)
                {
                    if (((CheckBox)this.gvConmanShip.Rows[i].Cells[0].Controls[1]).Checked == true)
                    {
                        int ConmanShipID = UtilTool.ToSafeInt32(this.gvConmanShip.DataKeys[i].Value);
                        new ConmanShipManager().DeleteConmanShipByID(ConmanShipID);
                    }
                }
                this.BindPageIndex(1);
            }
            catch (Exception ex)
            {
                this.lblMessage.Text = ex.Message;
            }
        }    /// <summary>
        /// 实现挂起功能
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUP_Click(object sender, EventArgs e)
        {
            try
            {
                for (int i = 0; i < this.gvConmanShip.Rows.Count; i++)
                {
                    if (((CheckBox)this.gvConmanShip.Rows[i].Cells[0].Controls[1]).Checked == true)
                    {
                        int ConmanShipID = UtilTool.ToSafeInt32(gvConmanShip.DataKeys[i].Value);
                        new ConmanShipManager().UpdateConmanShipID(ConmanShipID,16,CurrentMember.CurrentMemberID,DateTime.Now);
                    }
                }
                this.BindPageIndex(1);
            }
            catch (Exception ex)
            {
                this.lblMessage.Text = ex.Message;
            }
        }    /// <summary>
        /// 实现通过功能
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnPass_Click(object sender, EventArgs e)
        {
            try
            {
                for (int i = 0; i < this.gvConmanShip.Rows.Count; i++)
                {
                    if (((CheckBox)this.gvConmanShip.Rows[i].Cells[0].Controls[1]).Checked == true)
                    {
                        int ConmanShipID = UtilTool.ToSafeInt32(gvConmanShip.DataKeys[i].Value);
                        new ConmanShipManager().UpdateConmanShipID(ConmanShipID, 17, CurrentMember.CurrentMemberID, DateTime.Now);
                    }
                }
                this.BindPageIndex(1);
            }
            catch (Exception ex)
            {
                this.lblMessage.Text = ex.Message;
            }
        }    /// <summary>
        /// 绑定下拉列表
        /// </summary>
        private void BindDropDownListType()
        {
            DataTable dtConmanShip = TypesManager.GetTypeByParentAndCategory(CTypesCategory.ConmanShipType.ID, 0);
            UtilTool.SetData(this.drpConmanShip, dtConmanShip);
            this.drpConmanShip.SelectedIndex = 0;
        }    /// <summary>
        /// 绑定单选按钮    /// </summary>
        public void BindRadioButtonList()
        {
            DataSet dsucRadioButtonList = new TypeCategoryManager().GetTypeByParentIDCategoryID(CTypesCategory.StateType.ID, 0);
            UtilTool.SetData(this.rblConmanShip, dsucRadioButtonList.Tables[0], "ID", "Name");
            this.rblConmanShip.SelectedIndex = 1;
        }    /// <summary>
        /// 实现GRIDVIEW页面行的绑定!
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvConmanShip_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            try
            {
                if (e.Row.RowIndex > -1)
                {
                    e.Row.Cells[1].Text = "<a target='_blank' href='ConmanShipBrowse.aspx?ConmanShipID=" + Tool.UtilTool.ToSafeInt32(gvConmanShip.DataKeys[e.Row.RowIndex].Value) + "'>" + e.Row.Cells[1].Text + "</a>";                if (e.Row.RowType == DataControlRowType.DataRow)
                    {
                        if (e.Row.RowType != DataControlRowType.Header)
                        {
                            e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#cccccc'");
                            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#ffffff'");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.lblMessage.Text = ex.Message;
            }
        }