数组访问越界
using System;using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=fjx;User ID=sa;Password=1234");
SqlCommand com = conn.CreateCommand();
= "select * from Department";
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = com;
DataSet ds = new DataSet();
conn.Open();
da.Fill(ds);
conn.Close();
int i = ds.Tables[0].Rows.Count;
if (i>0)
{
int iRow = ds.Tables[0].Rows.Count;
int iColumn = 2;
for (int j = 0; j < iRow; j++)
{
TableRow newRow = new TableRow();
tblshow.Controls.Add(newRow);
for (int k = 0; k < iColumn; k++)
{
TableCell newCell = new TableCell();
string strContent = "";
if (k == 0)
{
int iIndex = j + 1;
strContent = iIndex.ToString();
}
else
{
strContent = ds.Tables[0].Rows[j][k].ToString();
}
newCell.Text = strContent;
newRow.Controls.Add(newCell);
}
}
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("~\\Default.aspx/");
}
}运行后提示我数组访问越界,什么问题