我在学习用asp.net时遇到一个问题代码如下:
ST_CourseBiz.ST_Dept st_dept=new ST_CourseBiz.ST_Dept();
if(Request["Action"]=="add")
{
st_dept.ST_InsertDeptInfo(txtName.Text.Trim(),int.Parse(txtNumber.Text));
}
else
{
st_dept.ST_UpdateDeptInfo(txtName.Text.Trim(),int.Parse(txtNumber.Text));
string str="<script language=javascript>window.dialogArguments.document.location.href='ST_Dept.aspx';window.close();</script>";
Response.Write(str);
}
其中Request["Action"]里的Action是怎样赋值的?
ST_CourseBiz.ST_Dept st_dept=new ST_CourseBiz.ST_Dept();
if(Request["Action"]=="add")
{
st_dept.ST_InsertDeptInfo(txtName.Text.Trim(),int.Parse(txtNumber.Text));
}
else
{
st_dept.ST_UpdateDeptInfo(txtName.Text.Trim(),int.Parse(txtNumber.Text));
string str="<script language=javascript>window.dialogArguments.document.location.href='ST_Dept.aspx';window.close();</script>";
Response.Write(str);
}
其中Request["Action"]里的Action是怎样赋值的?
解决方案 »
- 有没有根据value查找key的方法???
- 关于数据库设计性能 使用视图好还是多写信息到表里??
- 我是名新手。。如何学好C#请各位前辈指教一下。。。
- 问个枚举问题。枚举类型字典在项目开发中的作用
- 请教 C# winform程序+webservice数据分页显示问题?
- 请高手指教!菜鸟的问题!
- 如何取得系统的版本语言?急呀
- 在asp.net中,请教框架的使用问题
- raw套字的问题
- 高手帮忙,如何用C#操作.ini文件,读和写,仅有的30分了
- 求助 C# 在dataGridView中加ComboBox 并帮定到相应数据库的字段上 源码 ~~~~~~~~~~~~~~~~急!
- 用户 '(null)' 登录失败。原因: 未与信任 SQL Server 连接相关联
如从A页面转到B页面: 则可在A页面的后台代码里写 Respose.Redirect("b.aspx?Action=add");
同样B页面的后台代码里则可以写 if(Request["Action"]=="add")
这种在URL后面用?传递参数的方法为GET方法,还有POST,这两种是最常用的
取时用Request.QueryString["Action"]
还可以用cookie session application 和静态变量传值
public void dgItem(object sender,DataGridCommandEventArgs e)
{
ST_CourseBiz.ST_Dept st_dept=new ST_CourseBiz.ST_Dept();
int st_deptID=int.Parse(e.Item.Cells[0].Text);
if(e.CommandName=="edit")
{
string str="<script language='javascript' defer>ret=window.showModalDialog('ST_DeptAdd.aspx',' Action=edit&id="+st_deptID+"','dialogHeight;250px;dialogWidth:600px;center:Yes;Help:No;Resizable:No;Scroll;auto;Status:no;');</script>";
Response.Write(str);
if(e.CommandName=="delete")
{
st_dept.ST_DeleteDeptInfo(st_deptID);
}
ST_DgBind();
}
}
但是在用到
if(Request["Action"]=="add")
{
st_dept.ST_InsertDeptInfo(txtName.Text.Trim(),int.Parse(txtNumber.Text));
}
else
{
st_dept.ST_UpdateDeptInfo(txtName.Text.Trim(),int.Parse(txtNumber.Text));
string str="<script language=javascript>window.dialogArguments.document.location.href='ST_Dept.aspx';window.close();</script>";
Response.Write(str);
}
时不对,ST_UpdateDeptInfo绑定不了,但是去掉if(Request["Action"]=="add")就可以,不知道哪里出的问题?
比如先定义一个string a ="111";
然后取值a = Convert.ToString(Request.QueryString["Action"]);
你先 Response.Wirte(a);把你取的值输出 看看得到的是什么
如果是111 则没取到 你测试下