帮我看看这段代码

zhanghu1986 2008-05-24 01:01:06
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>");?
...全文
38 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
周公 2008-05-24
  • 打赏
  • 举报
回复
if (mobilelist[i].Length > 12 ¦ ¦ mobilelist[i].Length < 11)
这句有问题
看看mobilelist[i].Length到底是多少?
toxxj 2008-05-24
  • 打赏
  • 举报
回复
去掉: string[] mobilelist = null;
改成:
string[] mobilelist = Regex.Split(mobile, "\r\n", RegexOptions.IgnoreCase);

62,041

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧