关于ID获得问题 当然是用Request.QueryString了。 if (Request.QueryString["id"] != null) { string Id = Request.QueryString["Id"].ToString(); } 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用Session传值前一个页面内.cs中,Session["ID"] = ?;x.aspx.cs中, string id = Session["ID"].ToString();最好先在globle配制文件中声明Session["ID"]并赋null 用 Request了if(!string.IsNullOrEmpty(Request["id"])){ string Id = Request["Id"]; } 用Request.QueryString就可以了,不用session 我把 x.aspx.cs中写下如下代码,调用 string strConnection = "server=local;uid=sa;pwd=sa;database=dbname"; SqlConnection objConnection = new SqlConnection(strConnection); objConnection.Open(); SqlCommand cmd = new SqlCommand("SELECT * FROM class where classID=Request.QueryString['Id']", objConnection); SqlDataReader dr = cmd.ExecuteReader(); string strBody1 = null; string strBody2 = null; dr.Read() strBody1 += "" + dr["name"] + ""; strBody1 += "" + dr["show"] + ""; dr.Close(); objConnection.Close(); return strBody;请问这样写对吗?如果我要在aspx文件中分别显示出name和show,改怎么办呢?谢谢 private string id = null; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { id = Request.QueryString["id"]; Response.Write(id); } } public string GetStrBody(){string strConnection = "server=local;uid=sa;pwd=sa;database=dbname"; SqlConnection objConnection = new SqlConnection(strConnection); objConnection.Open(); SqlCommand cmd = new SqlCommand("SELECT * FROM class where classID=Request.QueryString['Id']", objConnection); SqlDataReader dr = cmd.ExecuteReader(); string strBody1 = null; string strBody2 = null; dr.Read() strBody1 += "" + dr["name"] + ""; strBody1 += "" + dr["show"] + ""; dr.Close(); objConnection.Close(); return strBody; }protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string strBody=GetStrBody(); string[] arry = strBody.split(''); string name = arry[0]; string show = arry[1]; this.TextBox1.Text = name;this.TextBox2.Text = show; } } aspx.cs文件public partial class _1 : System.Web.UI.Page{ public string GetStrBody() { //链接数据库并打开读取 string strBody1 = null; string strBody2 = null; dr.Read() strBody1 += "" + dr["title"] + ""; strBody1 += "" + dr["content"] + ""; dr.Close(); objConnection.Close(); return strBody; } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string strBody=GetStrBody(); string[] arry = strBody.split(''); string name = arry[0]; string show = arry[1]; this.TextBox1.Text = name; this.TextBox2.Text = show; } }}aspx文件 <form runat="server"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> </form>我运行了,一直提示“ 编译器错误信息: CS1011: Empty character literal”错误,在 string[] arry = strBody.split(''); 这一行,请问改怎么解决呢? MDI 子窗口布局问题求教 GridView的问题 郁闷~透明图片放置在控件上 无法透明 100分 问类的问题 求助:Host Evidence 是什么意思? Windows Vista 隐含着天大的谎言? winform 实现网页源码获取--问题--在线等 问两个新手基础问题 我花了1.5天的时间,在网上想找一个2005集成SP1的映像文件,结果使我哭的一败图地,没有!! 如何判断一个MDI子窗体是否存在于子窗体数组中? use java.util.zip in NET 水晶报表OLE图片无法显示(在线等)
前一个页面内.cs中,Session["ID"] = ?;
x.aspx.cs中, string id = Session["ID"].ToString();
最好先在globle配制文件中声明Session["ID"]并赋null
if(!string.IsNullOrEmpty(Request["id"]))
{
string Id = Request["Id"];
}
string strConnection = "server=local;uid=sa;pwd=sa;database=dbname";
SqlConnection objConnection = new SqlConnection(strConnection);
objConnection.Open();
SqlCommand cmd = new SqlCommand("SELECT * FROM class where classID=Request.QueryString['Id']", objConnection);
SqlDataReader dr = cmd.ExecuteReader();
string strBody1 = null;
string strBody2 = null;
dr.Read()
strBody1 += "" + dr["name"] + "";
strBody1 += "" + dr["show"] + "";
dr.Close();
objConnection.Close();
return strBody;请问这样写对吗?
如果我要在aspx文件中分别显示出name和show,改怎么办呢?谢谢
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
id = Request.QueryString["id"];
Response.Write(id);
}
}
public string GetStrBody()
{
string strConnection = "server=local;uid=sa;pwd=sa;database=dbname";
SqlConnection objConnection = new SqlConnection(strConnection);
objConnection.Open();
SqlCommand cmd = new SqlCommand("SELECT * FROM class where classID=Request.QueryString['Id']", objConnection);
SqlDataReader dr = cmd.ExecuteReader();
string strBody1 = null;
string strBody2 = null;
dr.Read()
strBody1 += "" + dr["name"] + "";
strBody1 += "" + dr["show"] + "";
dr.Close();
objConnection.Close();
return strBody;
}protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string strBody=GetStrBody();
string[] arry = strBody.split('');
string name = arry[0];
string show = arry[1];
this.TextBox1.Text = name;
this.TextBox2.Text = show; }
}
{
public string GetStrBody()
{
//链接数据库并打开读取
string strBody1 = null;
string strBody2 = null;
dr.Read()
strBody1 += "" + dr["title"] + "";
strBody1 += "" + dr["content"] + "";
dr.Close();
objConnection.Close();
return strBody;
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string strBody=GetStrBody();
string[] arry = strBody.split('');
string name = arry[0];
string show = arry[1];
this.TextBox1.Text = name;
this.TextBox2.Text = show; }
}}aspx文件 <form runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</form>我运行了,一直提示“ 编译器错误信息: CS1011: Empty character literal”错误,在 string[] arry = strBody.split(''); 这一行,请问改怎么解决呢?