请教^^^^^^关于TextBox的内容无法实现修改,不知是何原因? 你的TextBox初始化语句 要放在if(!Page.IsPostBack) 中 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 selectindexchange()是不是在page_load()里也调用了阿 发现在点击了提交button后button的OnClick内好像有调用了selectindexchange()我怎么都看不出来 哪里有引发了ddl的selectindexchange啊protected void btnEditTemplate_Click(object sender,EventArgs e) { string str1=txtTemplateName.Text; string str2=txtTemplateContent.Text; string str3=lstTemplateName.SelectedItem.Value; string str4=lstTemplateName.SelectedItem.Text; OleDbCommand commTest=new OleDbCommand("select count(*) from Template where TemplateName='"+txtTemplateName.Text+"'",Conn); Conn.Open(); int i=int.Parse(commTest.ExecuteScalar().ToString()); Conn.Close(); if(i>0) { Response.Write("<script>alert('已经有此名称的模板存在');</script>"); } else { string strInsert; if(str1=="") { Response.Write("<script>alert('"+str2+"');</script>"); strInsert="update Template set TemplateContent= '"+str2+"' where ID= "; strInsert+=str3; Response.Write("<script>alert('"+strInsert+"');</script>"); } else { strInsert="update Template set TemplateName='"+str1+"',TemplateContent= '"+str2+"' where ID= "; strInsert+=str3; string strUpdate="update Article set TemplateName='"+str1+"' where TemplateName='"+str4+"'"; Conn.Open(); OleDbCommand comm2=new OleDbCommand(strUpdate,Conn); comm2.ExecuteNonQuery(); Conn.Close(); } Conn.Open(); OleDbCommand comm=new OleDbCommand(strInsert,Conn); comm.ExecuteNonQuery(); Conn.Close(); } } 我也遇到过这种情况,就像Englishgenius(白天遛鸟晚上洗澡)说得一样你的TextBox初始化语句 要放在if(!Page.IsPostBack) 中 这样就可以解决了! to: ugg(许优) 我已经放倒if(!Page.IsPostBack) 中了 但是仍然不对按钮点击后竟然可以引发DDL的autopostback,郁闷 autopostback是不是都申明了? 只在DDL中申明了AUTOPOSTBACK我纳闷的是 为何提交按钮会触发DDL的autopostback而引发了selectIndexchange AUTOPOSTBACK为true的textbox建议用会话状态! to:szwebnet(动力)textbox没有设autopostback啊,只是DDL用了AUTOPOSTBACK并在selectindexchange内给TEXTBOX赋值,但赋值后 我手工更改了TEXTBOX的内容 点击提交button 却还能激发DDL的autopostback 导致TEXTBOX的内容提交倒数据库内的仍然是改前的值 恕本人无知.你所谓的DDL是什么?Data Definition Language?就算不是.即然是autopostback,那还用button去激发?不解中~ to: szwebnet(动力) DDL我指的是dropdownlist我设计是当DDL选项发生改变时 textbox的也随着内容也发生改变,比如通过选择DDL内的一个IDtextbox内容显示为此ID相对应的name值,这个已经通过ddl的autopostback+selectindexchange对应的方法实现。然后修改手工textbox内容点击button提交可以修改name的值。问题是button点击后又引发了ddl的selectindexchanged那个方法导致textbox的内容又回倒手工更改前并提交倒数据库了,即修改未成功。但button的click()内更本没有掉用ddl的selectindexchanged那个方法导致啊button的click代码已经在上边贴着。 搞定 ~~~viewstate的问题 感谢大家热心帮助 结贴! 购物车实现 cookies的问题。。求解啊。。。 html button click事件发生前一定会发生focus事件吗? 关于防火墙的问题 e.Item.ItemIndex == 0,怎么让记录从当前位置开始上一条或下一条. datagrid增加新行 DataSet更新字段名出现问题 关于TextBox的循环命名? 使用Session如何传递参数; 哪里可以找到合适的相关教程 windows10 打开iis服务器的问题 我写的上传程序为何上传不了呢,麻烦帮我看看,多谢了! ASP.NET 中如何解决因刷新而再次提交数据的问题?
我怎么都看不出来 哪里有引发了ddl的selectindexchange啊protected void btnEditTemplate_Click(object sender,EventArgs e)
{
string str1=txtTemplateName.Text;
string str2=txtTemplateContent.Text;
string str3=lstTemplateName.SelectedItem.Value;
string str4=lstTemplateName.SelectedItem.Text;
OleDbCommand commTest=new OleDbCommand("select count(*) from Template where TemplateName='"+txtTemplateName.Text+"'",Conn);
Conn.Open();
int i=int.Parse(commTest.ExecuteScalar().ToString());
Conn.Close();
if(i>0)
{
Response.Write("<script>alert('已经有此名称的模板存在');</script>");
}
else
{
string strInsert;
if(str1=="")
{
Response.Write("<script>alert('"+str2+"');</script>");
strInsert="update Template set TemplateContent= '"+str2+"' where ID= ";
strInsert+=str3;
Response.Write("<script>alert('"+strInsert+"');</script>");
}
else
{
strInsert="update Template set TemplateName='"+str1+"',TemplateContent= '"+str2+"' where ID= ";
strInsert+=str3;
string strUpdate="update Article set TemplateName='"+str1+"' where TemplateName='"+str4+"'";
Conn.Open();
OleDbCommand comm2=new OleDbCommand(strUpdate,Conn);
comm2.ExecuteNonQuery();
Conn.Close();
}
Conn.Open();
OleDbCommand comm=new OleDbCommand(strInsert,Conn);
comm.ExecuteNonQuery();
Conn.Close();
}
}
你的TextBox初始化语句 要放在
if(!Page.IsPostBack) 中
这样就可以解决了!
我已经放倒if(!Page.IsPostBack) 中了 但是仍然不对
按钮点击后竟然可以引发DDL的autopostback,郁闷
是不是都申明了?
我纳闷的是 为何提交按钮会触发DDL的autopostback而引发了selectIndexchange
textbox没有设autopostback啊,只是DDL用了AUTOPOSTBACK并在selectindexchange内给TEXTBOX赋值,但赋值后 我手工更改了TEXTBOX的内容 点击提交button 却还能激发DDL的autopostback 导致TEXTBOX的内容提交倒数据库内的仍然是改前的值
Data Definition Language?就算不是.即然是autopostback,那还用button去激发?不解中~
DDL我指的是dropdownlist
我设计是当DDL选项发生改变时 textbox的也随着内容也发生改变,比如通过选择DDL内的一个ID
textbox内容显示为此ID相对应的name值,这个已经通过ddl的autopostback+selectindexchange对应的方法实现。
然后修改手工textbox内容点击button提交可以修改name的值。
问题是button点击后又引发了ddl的selectindexchanged那个方法导致textbox的内容又回倒手工更改前并提交倒数据库了,即修改未成功。
但button的click()内更本没有掉用ddl的selectindexchanged那个方法导致啊button的click代码已经在上边贴着。
感谢大家热心帮助 结贴!