谢谢,请问一下怎么联系kotao_78 ?
解决方案 »
- autocad二次开发 blockreference应用?
- 请教高手网站后台的留言管理功能
- 163新闻浏览状态保存怎么写
- (本人的项目有多层框架)请问在c#后台 如何控制顶级框架的url的跳转~~~多谢
- ???急用:如何在asp.NET(C#)中调用C++Builder编写的DLL文件?在线等...
- 用什么工具能在进行类设计时,使设计和C#的类的代码同步??? 散分...
- 在程序中用WINDOWS API函数怎么去设置ODBC DSN!程序怎么实现呢!急!急!急!
- 《深入剖析ASP.NET组件设计》这本书我已经看晕了
- 是我的vs编译器出问题了吗?
- 再请教自定义控件中的javascript问题?
- 怎么看不到了。
- 如何发布用asp.net作的web程序?
代码全给你,看着办吧!//mibaomin
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;namespace KMSWebApp
{
/// <summary>
/// SortManager 的摘要说明。
/// </summary>
public class SortManager : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.Button bt_Add;
protected System.Web.UI.WebControls.Label lb_Sort;
protected System.Web.UI.WebControls.Button bt_Cancel;
protected System.Web.UI.WebControls.Button bt_Submit;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!IsPostBack)
{
//此代码是传进来的参数
ViewState["sort"]=Request.QueryString["sort"].ToString();
//ViewState["sort"]="收文类型";
BindGrid();
DisableDataGrid();
bt_Submit.Enabled=false;
bt_Cancel.Enabled=false;
}
} #region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.bt_Add.Click += new System.EventHandler(this.bt_Add_Click);
this.bt_Submit.Click += new System.EventHandler(this.bt_Submit_Click);
this.bt_Cancel.Click += new System.EventHandler(this.bt_Cancel_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void DisableDataGrid()
{
foreach(DataGridItem dgi in DataGrid1.Items)
{
TextBox tb=(TextBox)(dgi.Cells[1].Controls[1]);
tb.Enabled=false;
}
} private void EnableDataGrid()
{
foreach(DataGridItem dgi in DataGrid1.Items)
{
TextBox tb=(TextBox)(dgi.Cells[1].Controls[1]);
tb.Enabled=true;
}
} private void BindGrid()
{
string sort=ViewState["sort"].ToString();
string sql="select iId,cParamValue from t_EnumType where bDel=0 and cParamDescription='"+sort+"' order by iId Desc";//+Session["Sort"];
DataSet ds=publicClass.DataBase.ReturnDataSet(sql);
ViewState["ds"]=ds;
DataView myview=ds.Tables[0].DefaultView;
DataGrid1.DataSource=myview;
DataGrid1.DataBind();
} private void bt_Submit_Click(object sender, System.EventArgs e)
{
DataGridItem dgi = DataGrid1.Items[0];
string Description=ViewState["sort"].ToString();
string Value=((TextBox)dgi.Cells[1].Controls[1]).Text.Trim();
if(Value!=""&&Value!=null)
{
string sql="insert t_EnumType(cParamDescription,cParamValue,bDel) values('"+Description+"','"+Value+"',0)";
try
{
publicClass.DataBase.ModifyData(sql);
}
catch
{
publicClass.ShowDialog("类型名称已经存在!",this);
}
BindGrid();
bt_Add.Enabled=true;
bt_Cancel.Enabled=false;
bt_Submit.Enabled=false;
DisableDataGrid();
Response.Write("<script>if (window.opener!=null) window.opener.location.href=window.opener.location.href;</script>");
}
else
{
publicClass.ShowDialog("添加失败!类别名称不能为空值!!",this);
}
} private void bt_Add_Click(object sender, System.EventArgs e)
{
DataSet ds=(DataSet)ViewState["ds"];
DataRow newrow=ds.Tables[0].NewRow();
newrow[0]=0;
newrow[1]="";
ds.Tables[0].Rows.InsertAt(newrow,0);
DataGrid1.DataSource=ds.Tables[0].DefaultView;
DataGrid1.DataBind(); bt_Submit.Enabled=true;
bt_Cancel.Enabled=true;
bt_Add.Enabled =false;
DisableDataGrid();
TextBox tb=(TextBox)(DataGrid1.Items[0].Cells[1].Controls[1]);
tb.Enabled=true;
} private void bt_Cancel_Click(object sender, System.EventArgs e)
{
BindGrid();
bt_Submit.Enabled=false;
bt_Cancel.Enabled=false;
bt_Add.Enabled =true;
DisableDataGrid();
}
}
}
代码全给你,看着办吧!//mibaomin
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;namespace KMSWebApp
{
/// <summary>
/// SortManager 的摘要说明。
/// </summary>
public class SortManager : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.Button bt_Add;
protected System.Web.UI.WebControls.Label lb_Sort;
protected System.Web.UI.WebControls.Button bt_Cancel;
protected System.Web.UI.WebControls.Button bt_Submit;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!IsPostBack)
{
//此代码是传进来的参数
ViewState["sort"]=Request.QueryString["sort"].ToString();
//ViewState["sort"]="收文类型";
BindGrid();
DisableDataGrid();
bt_Submit.Enabled=false;
bt_Cancel.Enabled=false;
}
} #region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.bt_Add.Click += new System.EventHandler(this.bt_Add_Click);
this.bt_Submit.Click += new System.EventHandler(this.bt_Submit_Click);
this.bt_Cancel.Click += new System.EventHandler(this.bt_Cancel_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void DisableDataGrid()
{
foreach(DataGridItem dgi in DataGrid1.Items)
{
TextBox tb=(TextBox)(dgi.Cells[1].Controls[1]);
tb.Enabled=false;
}
} private void EnableDataGrid()
{
foreach(DataGridItem dgi in DataGrid1.Items)
{
TextBox tb=(TextBox)(dgi.Cells[1].Controls[1]);
tb.Enabled=true;
}
} private void BindGrid()
{
string sort=ViewState["sort"].ToString();
string sql="select iId,cParamValue from t_EnumType where bDel=0 and cParamDescription='"+sort+"' order by iId Desc";//+Session["Sort"];
DataSet ds=publicClass.DataBase.ReturnDataSet(sql);
ViewState["ds"]=ds;
DataView myview=ds.Tables[0].DefaultView;
DataGrid1.DataSource=myview;
DataGrid1.DataBind();
} private void bt_Submit_Click(object sender, System.EventArgs e)
{
DataGridItem dgi = DataGrid1.Items[0];
string Description=ViewState["sort"].ToString();
string Value=((TextBox)dgi.Cells[1].Controls[1]).Text.Trim();
if(Value!=""&&Value!=null)
{
string sql="insert t_EnumType(cParamDescription,cParamValue,bDel) values('"+Description+"','"+Value+"',0)";
try
{
publicClass.DataBase.ModifyData(sql);
}
catch
{
publicClass.ShowDialog("类型名称已经存在!",this);
}
BindGrid();
bt_Add.Enabled=true;
bt_Cancel.Enabled=false;
bt_Submit.Enabled=false;
DisableDataGrid();
Response.Write("<script>if (window.opener!=null) window.opener.location.href=window.opener.location.href;</script>");
}
else
{
publicClass.ShowDialog("添加失败!类别名称不能为空值!!",this);
}
} private void bt_Add_Click(object sender, System.EventArgs e)
{
DataSet ds=(DataSet)ViewState["ds"];
DataRow newrow=ds.Tables[0].NewRow();
newrow[0]=0;
newrow[1]="";
ds.Tables[0].Rows.InsertAt(newrow,0);
DataGrid1.DataSource=ds.Tables[0].DefaultView;
DataGrid1.DataBind(); bt_Submit.Enabled=true;
bt_Cancel.Enabled=true;
bt_Add.Enabled =false;
DisableDataGrid();
TextBox tb=(TextBox)(DataGrid1.Items[0].Cells[1].Controls[1]);
tb.Enabled=true;
} private void bt_Cancel_Click(object sender, System.EventArgs e)
{
BindGrid();
bt_Submit.Enabled=false;
bt_Cancel.Enabled=false;
bt_Add.Enabled =true;
DisableDataGrid();
}
}
}
动态创建的Table一提交就清空了,怎么保存呢? 请教!!!