“索引超出范围。必须是非负数且小于集合参数名称的大小:index。这是一个屏幕截图: This is the bug from my app当我选择要打印的文档时,应用程序将随机打印其他文档。请你的帮助大师:( 这是我的代码:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
trackingDataContext dc = new trackingDataContext(MyClass.conn);
if (e.CommandName == "Print")
{
int row = Int32.Parse(e.CommandArgument.ToString()) + (GridView1.PageIndex * GridView1.PageSize);
GridViewRow gr = GridView1.Rows[row];
string ID = gr.Cells[0].Text;
string jenis_dokumen = gr.Cells[2].Text;
string nopek = gr.Cells[4].Text;
string rdl = "";
var td = (from t in dc.tracking_dokumens where t.id == Convert.ToInt16(ID) select t).SingleOrDefault();
var area = (from a in dc.field_lists where a.id == td.field_id select a).SingleOrDefault();
if (area.field_name == "Kantor Pusat Jakarta")
{
if (jenis_dokumen == "SPD")
{
rdl = "deklarasi.rdl";
}
else if (jenis_dokumen == "Panjar Dinas")
{
rdl = "panjar_dinas.rdl";
}
else if (jenis_dokumen == "Pengajuan Panjar Kerja")
{
rdl = "panjar_kerja.rdl";
}
else if (jenis_dokumen == "SP3")
{
rdl = "sp3.rdl";
}
else if (jenis_dokumen == "Pertanggungjawaban Panjar Kerja")
{
rdl = "pertanggungjawaban.rdl";
}
}
else
{
if (jenis_dokumen == "SPD")
{
rdl = "deklarasi_area.rdl";
}
else if (jenis_dokumen == "Panjar Dinas")
{
rdl = "panjar_dinas_area.rdl";
}
else if (jenis_dokumen == "Pengajuan Panjar Kerja")
{
rdl = "panjar_kerja_area.rdl";
}
else if (jenis_dokumen == "SP3")
{
rdl = "sp3_area.rdl";
}
else if (jenis_dokumen == "Pertanggungjawaban Panjar Kerja")
{
rdl = "pertanggungjawaban_area.rdl";
}
}
Response.Redirect(MyClass.Site + "/_layouts/ReportServer/RSViewerPage.aspx?rv:RelativeReportUrl=/sites/tracking/Report/"+rdl+"&Source="+MyClass.Site+"/Report/Forms/AllItems.aspx&DefaultItemOpen=1&rp:nopek="+nopek+"&rp:id="+ID);
}
}
答案 0 :(得分:-1)
检查发生异常的索引和数组大小。你显然是想让索引上的项目为负数或超过(数组中的项目数 - 1)。