帮我看看这段代码
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>");?