protected void Page_Load(object sender, EventArgs e)
{
if (mes == "2" && action == "edit")
{
gq.Visible = false;
zp.Visible = true;
Button3.Text = "修改";
SqlConnection myConn = new SqlConnection(conn);
myConn.Open();
string sql = ("select * from db24 where db1='" + id + "'AND id='"+ mes_id +"'");
SqlCommand comm = new SqlCommand(sql, myConn);
SqlDataReader rd = comm.ExecuteReader();
//string pwd = this.txtPwd.Text;
if (rd.Read())
{
zp_db2.Text=rd["db2"].ToString(); }
myConn.Close();
}
protected void Button3_Click(object sender, EventArgs e)
{
if (action == "edit" && mes=="2")
{
SqlConnection myConn = new SqlConnection(conn);
myConn.Open();
string Sql = "update db24 set db2='"+zp_db2.Text+"' where db1='" + id + "' AND id='"+ mes_id +"'";
SqlCommand com = new SqlCommand(Sql, myConn);
SqlDataReader da = com.ExecuteReader();
myConn.Close();
Page.Response.Redirect("../login/main.aspx");
}
}
}
上面是代码~!!div的Visible初始属性都是"false",update的时候取不到zp_db2(这个是个textbox)的值了````
请大大们帮忙解决一下````这段代码没有错,我把update中的zp_db2换成别的变量都好用,感觉就是因为Visible="false"影响取值`````
解决方案 »
- 简单 问题 下班结帖!!(2010-10-20)
- 请问如何实现"图层"?
- 在asp.net中,声明了doctype后,有个js文件不能正常显示,但是不声明呢,css就失效了。
- ajaxpro读取缓存的问题
- |zyciis| 求CSDN网站中的用户登录是如何在多个他的子网里面共存的 谢谢
- ASP.Net网站发布问题.相对路径问题。
- 请教高手,datagrid有3个button,不是模板列,如何点击一个button隐藏掉3个button
- 急寻论文思路
- 关于DataGrid的显示模式
- 我在学做组件,请问如何在组件里面控制Session?
- 一个我搞不定的问题,希望高手来帮我解决下子!
- asp.net中 Gridview 为什么触发不了删除事件
//style.display="block"
這個可以避免上述問題
div.style.display="none";
<head runat="server">
<title>无标题页</title>
<script>
function aa()
{
var b=document.getElementById('txtinput').value;
alert(b);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div style="display:none">
<input type="text" id="txtinput" runat="server" value="123" />
</div>
<input type="button" onclick="aa()" />
</form>
</body>
</html>完全可以取值
会出现占位吗
处理方法:
1.<asp:hiddenField/>
2.控制css:style="display:block"(可见)/style="display:none"(隐藏)
如:<div runat="server" id="dv">
asdasdadasdasd </div>后台:dv.Style.Add("display", "none"); 隐藏 dv.Style.Remove("display"); 显示
{
if (mes == "2" && action == "edit")
{
gq.Visible = false;
zp.Visible = true;
Button3.Text = "修改";
SqlConnection myConn = new SqlConnection(conn);
myConn.Open();
string sql = ("select * from db24 where db1='" + id + "'AND id='"+ mes_id +"'");
SqlCommand comm = new SqlCommand(sql, myConn);
SqlDataReader rd = comm.ExecuteReader();
//string pwd = this.txtPwd.Text;
if (rd.Read())
{
hidd_id.Value=zp_db2.Text=rd["db2"].ToString(); }
myConn.Close();
}
protected void Button3_Click(object sender, EventArgs e)
{
if (action == "edit" && mes=="2")
{
SqlConnection myConn = new SqlConnection(conn);
myConn.Open();
string Sql = "update db24 set db2='"+hidd_id.Value+"' where db1='" + id + "' AND id='"+ mes_id +"'";
SqlCommand com = new SqlCommand(Sql, myConn);
SqlDataReader da = com.ExecuteReader();
myConn.Close();
Page.Response.Redirect("../login/main.aspx");
}
}
}
是这么写吗````````
没用过hiddenField -,- 请教了
那就可以不用zp_db2.Text了
"update db24 set db2='"+ViewState["参数"].ToString()+"' where db1='" + id + "' AND id='"+ mes_id +"'";
Page_Load里代码用if (!IsPostBack)
{
}括起来,为其他不用改
明白了```````
就读一次``````
疯了 以前都会写 !IsPostBack的```就这次忘了`````郁闷 谢谢 BernardSun 指教~!