我的一个产品资料更新页面里有多个文本框。开始能正确的显示绑定的内容(有汉字)。当点击了更新按钮后,有一个文本框里的内容就被三个问号代替了!其他的文本框都正常。我设置断点跟踪时发现那个显示布正常的文本框里的内容全部是很多看不懂的乱码。
哪位大哥帮帮我,这是为什么?
哪位大哥帮帮我,这是为什么?
解决方案 »
- 如何实现类似工具栏这样的功能
- 求助:Repeater问题。。。。。。。急!!
- U盘程序自启动
- 怎样用DropDownList控件的选择项去更新GridView控件中的一个列?
- .NET框架好像出现问题了,我应该如何修复?(100分急)
- 高分求DataGrid的鼠标事件
- 小弟新来宝地,弱弱的问一下,最好用过2005 Team Suite的大虾来帮忙
- 郁闷,散分!这是我该做的工作么?
- 怎样给WebControls.Toolbar上的ToolbarButton加一onclick事件,如显示删除确认对话框。
- 怎么全局监控到网站要跳转的链接?
- 如何弹出一个窗口给予信息
- 问一个chr(13)替换的问题,痛苦中....
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.Text.RegularExpressions;
using SeneLogic;namespace Seneschal.main.basic
{
/// <summary>
/// stapleUpdate 的摘要说明。
/// </summary>
public class stapleUpdate : System.Web.UI.Page
{
protected System.Web.UI.WebControls.ImageButton btnStaple;
protected System.Web.UI.WebControls.ImageButton btnProduct;
protected System.Web.UI.WebControls.ImageButton btnSupplier;
protected System.Web.UI.WebControls.ImageButton btnCustomer;
protected System.Web.UI.WebControls.ImageButton btnStore;
protected System.Web.UI.WebControls.ImageButton btnDepartment;
protected System.Web.UI.WebControls.ImageButton btnEmployee;
protected System.Web.UI.WebControls.ImageButton btnOther;
protected System.Web.UI.WebControls.Label lblStapleID;
protected System.Web.UI.WebControls.TextBox txtStapleName;
protected System.Web.UI.WebControls.TextBox txtSpecification;
protected System.Web.UI.WebControls.TextBox txtUpperLimit;
protected System.Web.UI.WebControls.TextBox txtLowerLimit;
protected System.Web.UI.WebControls.TextBox txtExplain;
protected System.Web.UI.WebControls.DropDownList cboTypeName;
protected System.Web.UI.WebControls.DropDownList cboSortName;
protected System.Web.UI.WebControls.DropDownList cboUnit;
protected System.Web.UI.WebControls.Button btnOK;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(Session["userID"] == null)
{
Response.Redirect("~/login.aspx");
}
else
{
if(!IsPostBack)
{
lblStapleID.Text = Request.QueryString["stapleID"];
InfoStaple cStaple = new InfoStaple();
DataTable dtStaple = new DataTable();
DataTable dtType = new DataTable();
DataTable dtSort = new DataTable();
DataTable dtUnit = new DataTable();
//得到此物料的当前详细信息。
dtStaple = cStaple.GetStapleInfo(lblStapleID.Text);
txtStapleName.Text = dtStaple.Rows[0]["stapleName"].ToString();
txtSpecification.Text = dtStaple.Rows[0]["specification"].ToString();
txtUpperLimit.Text = dtStaple.Rows[0]["upperLimit"].ToString();
txtLowerLimit.Text = dtStaple.Rows[0]["lowerLimit"].ToString();
txtExplain.Text = dtStaple.Rows[0]["explain"].ToString();
//绑定类别到组合框。
dtType = cStaple.GetAllStapleType();
cboTypeName.DataSource = dtType;
cboTypeName.DataTextField = "typeName";
cboTypeName.DataValueField = "typeID";
cboTypeName.DataBind();
for(int i=0;i<dtType.Rows.Count;i++)
{
if(cboTypeName.Items[i].Text == dtStaple.Rows[0]["typeName"].ToString())
{
//显示(选中)当前的类别。
cboTypeName.Items[i].Selected = true;
break;
}
}
//绑定当前类别下的类型到组合框。
dtSort = cStaple.GetAllStapleSort(int.Parse(cboTypeName.SelectedValue));
cboSortName.DataSource = dtSort;
cboSortName.DataTextField = "sortName";
cboSortName.DataValueField = "sortID";
cboSortName.DataBind();
for(int i=0;i<dtSort.Rows.Count;i++)
{
if(cboSortName.Items[i].Text == dtStaple.Rows[0]["sortName"].ToString())
{
//显示(选中)当前的类型。
cboSortName.Items[i].Selected = true;
break;
}
}
//绑定计量单位到组合框。
InfoUnit cUnit = new InfoUnit();
dtUnit = cUnit.GetAllUnitInfo();
cboUnit.DataSource = dtUnit;
cboUnit.DataTextField = "unitName";
cboUnit.DataValueField = "unitID";
cboUnit.DataBind();
for(int i=0;i<dtUnit.Rows.Count;i++)
{
if(cboUnit.Items[i].Text == dtStaple.Rows[0]["unitName"].ToString())
{
//显示(选中)当前的计量单位。
cboUnit.Items[i].Selected = true;
break;
}
}
}
}
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.btnStaple.Click += new System.Web.UI.ImageClickEventHandler(this.btnStaple_Click);
this.btnProduct.Click += new System.Web.UI.ImageClickEventHandler(this.btnProduct_Click);
this.btnSupplier.Click += new System.Web.UI.ImageClickEventHandler(this.btnSupplier_Click);
this.btnCustomer.Click += new System.Web.UI.ImageClickEventHandler(this.btnCustomer_Click);
this.btnStore.Click += new System.Web.UI.ImageClickEventHandler(this.btnStore_Click);
this.btnDepartment.Click += new System.Web.UI.ImageClickEventHandler(this.btnDepartment_Click);
this.btnEmployee.Click += new System.Web.UI.ImageClickEventHandler(this.btnEmployee_Click);
this.btnOther.Click += new System.Web.UI.ImageClickEventHandler(this.btnOther_Click);
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregionprivate void btnOK_Click(object sender, System.EventArgs e)
{
if(txtStapleName.Text == "")
{
Response.Write("<script>alert('物料名称不能为空!')</script>");
}
else
{
if(txtSpecification.Text == "")
{
Response.Write("<script>alert('物料规格型号不能为空!')</script>");
}
else
{
if(txtLowerLimit.Text == "")
{
Response.Write("<script>alert('物料库存下限不能为空!')</script>");
}
else
{
if(Regex.IsMatch(txtUpperLimit.Text,@"/[^\d]/g"))
{
Response.Write("<script>alert('物料库存上下限只能为数字,不能是其他字符!')</script>");
}
else
{
}
}
}
}
}
}
}问题就是当点击了btnOK后出现的,就是txtStapleName这个文本框。加载页面时能正确显示。