出现原因:
1。未给URL参数。
2。request["text"+i+""]的做法是不行的 楼主可以试试用字符串拼接的方式
如:http://www.xxx.com?text=1,2,3,4;(1,2,3,4)在后台取request["text"]的值,用","分隔就行了
1。未给URL参数。
2。request["text"+i+""]的做法是不行的 楼主可以试试用字符串拼接的方式
如:http://www.xxx.com?text=1,2,3,4;(1,2,3,4)在后台取request["text"]的值,用","分隔就行了
sql += "&time1=" + intime.Text;
sql += "&time2=" + outtime.Text;
sql += "&money1=" + money1.ToString();
sql += "&money2=" + money2.ToString();
if (Server.UrlEncode(hotelname.Text) != "")
{
sql += "&hotelname=" + Server.UrlEncode(hotelname.Text);
}
else
{
sql += "&hotelname={empty}";
}
Response.Redirect("~/bookhotel/default.aspx?" + sql); {
//获取url的参数
string CityName = Server.UrlDecode(Request["city"]);//城市名字
DateTime Time1 = Convert.ToDateTime(Request["time1"]);//入住时间
DateTime Time2 = Convert.ToDateTime(Request["time2"]);//离店时间
decimal Money1 = decimal.Parse(Request["money1"]);//价格1(低)
decimal Money2 = decimal.Parse(Request["money2"]);//价格2(高)
FindControl知道吗?通过输入控件id来找到你要的那个控件 再强类型化他的控件类型0到i
string str;
for(int n=0 ; n++;n<=i)
{
str=((TextBox)FindControl("text"+n)).Text;
Response.Write(str);
}应该这样就好
或者可以用控件遍历来实现string str;
foreach (Control ct in form1.Controls )
{
if (typeof(TextBox) == ct.GetType())
{
str=((TextBox)ct).Text;
Response.Write(str);
}
}