0

根据数据库中的独特条件,我的网格只有一行(总是)。当我尝试编辑使用Rowcommand时出现错误

“索引超出范围”

这是网格代码和asp.net代码:

protected void grdedittemplate_RowCommand(object sender, GridViewCommandEventArgs e) {
    if (e.CommandName == "Update") {
        int index = e.commandargument;
        Label L0 = (Label) grd.Rows[index].Cells[0].Controls[1];
        value.Text = L0.Text;
        Label L1 = (Label) grd.Rows[index].Cells[1].Controls[1];
        value1.Text = L1.Text;
        Label L2 = (Label) grd.Rows[index].Cells[2].Controls[1];
        value2.Text = L2.Text;
        Label L3 = (Label) grd.Rows[index].Cells[3].Controls[1];
        value3.Text = L3.Text;
        Label L4 = (Label) grd.Rows[index].Cells[4].Controls[1];
        value4.Text = L4.Text;
        Label L5 = (Label) grd.Rows[index].Cells[5].Controls[1];
        value5.Text = .text Label L6 = (Label) grd.Rows[index].Cells[6].Controls[1];
        value6.Text = L6.Text;
    }
}
4

0 回答 0