string[] mobilelist = null;
bool flag = false;
protected void Button3_Click(object sender, EventArgs e)
{
string strPath = this.File1.Value + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls";
File1.PostedFile.SaveAs(strPath); string mystring = "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = '" + strPath + "';Extended Properties=Excel 8.0"; OleDbConnection cnnxls = new OleDbConnection(mystring); OleDbDataAdapter myDa = new OleDbDataAdapter("select * from [Sheet1$]", cnnxls); DataSet myDs = new DataSet(); myDa.Fill(myDs); GridView1.DataSource = myDs.Tables[0];
GridView1.DataBind();
}
protected void Button4_Click(object sender, EventArgs e)
{
mobilecheck();
if (flag == true)
{
if (mobilelist.Length < 200)
{
for (int i = 0; i < mobilelist.Length; i++)
{
Msg_send(mobilelist[i], std);
}
Response.Write("<script>alert('发送成功')</script>"); Response.Write("<script>window.location = 'Qf_SendMessage.aspx'</script>");
}
else
{
Response.Write("<script>alert('你发送的号码太多了,必须小于200')</script>");
}
}
}
protected void Button5_Click(object sender, EventArgs e)
{ }
protected void mobilecheck()
{
for (int i = 0; i < GridView1.Rows.Count; i++)
{
mobile += GridView1.Rows[0].Cells[0].Text.ToString() + "|";
} for (int i = 0; i < GridView1.Rows.Count; i++)
{
std += GridView1.Rows[0].Cells[1].Text.ToString() + "|";
}
if (mobile.Trim() == "")
{
Response.Write("<script>alert('号码不能为空');</script>");
flag = false;
return;
}
mobilelist = Regex.Split(mobile, "\r\n", RegexOptions.IgnoreCase);
for (int i = 0; i < mobilelist.Length; i++)
{
if (mobilelist[i].Length > 12 || mobilelist[i].Length < 11)
{
Response.Write("<script>alert('第" + i.ToString() + "号码错误,请重新输入号码!')</script>");
flag = false;
return;
}
}
flag = true;
}
当我运行这段代码的时候,明明第一行有值 为什么总是运行到这段代码了 Response.Write("<script>alert('第" + i.ToString() + "号码错误,请重新输入号码!')</script>");?
bool flag = false;
protected void Button3_Click(object sender, EventArgs e)
{
string strPath = this.File1.Value + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls";
File1.PostedFile.SaveAs(strPath); string mystring = "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = '" + strPath + "';Extended Properties=Excel 8.0"; OleDbConnection cnnxls = new OleDbConnection(mystring); OleDbDataAdapter myDa = new OleDbDataAdapter("select * from [Sheet1$]", cnnxls); DataSet myDs = new DataSet(); myDa.Fill(myDs); GridView1.DataSource = myDs.Tables[0];
GridView1.DataBind();
}
protected void Button4_Click(object sender, EventArgs e)
{
mobilecheck();
if (flag == true)
{
if (mobilelist.Length < 200)
{
for (int i = 0; i < mobilelist.Length; i++)
{
Msg_send(mobilelist[i], std);
}
Response.Write("<script>alert('发送成功')</script>"); Response.Write("<script>window.location = 'Qf_SendMessage.aspx'</script>");
}
else
{
Response.Write("<script>alert('你发送的号码太多了,必须小于200')</script>");
}
}
}
protected void Button5_Click(object sender, EventArgs e)
{ }
protected void mobilecheck()
{
for (int i = 0; i < GridView1.Rows.Count; i++)
{
mobile += GridView1.Rows[0].Cells[0].Text.ToString() + "|";
} for (int i = 0; i < GridView1.Rows.Count; i++)
{
std += GridView1.Rows[0].Cells[1].Text.ToString() + "|";
}
if (mobile.Trim() == "")
{
Response.Write("<script>alert('号码不能为空');</script>");
flag = false;
return;
}
mobilelist = Regex.Split(mobile, "\r\n", RegexOptions.IgnoreCase);
for (int i = 0; i < mobilelist.Length; i++)
{
if (mobilelist[i].Length > 12 || mobilelist[i].Length < 11)
{
Response.Write("<script>alert('第" + i.ToString() + "号码错误,请重新输入号码!')</script>");
flag = false;
return;
}
}
flag = true;
}
当我运行这段代码的时候,明明第一行有值 为什么总是运行到这段代码了 Response.Write("<script>alert('第" + i.ToString() + "号码错误,请重新输入号码!')</script>");?
解决方案 »
- cookie导致IE无法浏览服务器,急。
- js获得datalist的子控件
- 下面是bll层,我感觉bll层存在有必要么 public int GetMaxId() { return dal.GetMaxId(); } 啥
- 高分求教:Base-64 字符数组的无效长度
- 水晶报表的问题
- 程序中的 SESSION失效时间,和 IIS中的 连接失效时间 是一回事情吗?
- 做安装盘总是:其中用了水晶报表Crystal_Enterprise10,出错信息如下:
- 关于GridView的问题
- 如何使用DataGrid在表格中实现树型的表格!有加减号的!
- 偶尔出现的问题,不知是程序的问题还是IE的问题?高手进来看看!!
- 还是老问题---分页后删除事件的重新定向问题
- 来者有分,请各位介绍些优秀的论坛(尤其是美好些的),对自己论坛不满意,欲改版!
改成:
string[] mobilelist = Regex.Split(mobile, "\r\n", RegexOptions.IgnoreCase);
这句有问题
看看mobilelist[i].Length到底是多少?