在asp.net中显示表中的记录时出现问题

时间:2014-01-07 06:00:44

标签: mysql asp.net

通过查询,我从数据库中获取所有必需的记录,但所有记录都没有显示在显示表中。我无法找出为什么所有记录都没有显示。例如:如果我取6条记录,则只显示3条记录(显示奇数记录,即显示第1,第3和第5条记录)。

for (j = 0; j < chbStatuslist.Items.Count; j++)
        {
            if (chbStatuslist.Items[j].Selected)
            {
                carrStatus = chbStatuslist.Items[j].Value.Split('.');
                if (carrStatus.Length == 2)
                {
                    dTable = getConn.GetAdapterDatatable("SELECT cpCode, cpDate, cpNo,csShortName,pjName, cpComplaint, cpMobile, cpSev, cpCompBy, cpStatus FROM complaint,customermaster,project WHERE cpDel='R' and cpCustomer=csCode and cpProject=pjCode and (cpCustomer='" + cmbCustomer.SelectedValue + "' or 'ALL'='" + cmbCustomer.SelectedValue + "') and cpSev='" + cmbSev.SelectedItem + "' and cpDate between '" + cFDate + "' and '" + cTDate + "' and cpStatus>='" + carrStatus[0] + "' and cpStatus<='" + carrStatus[1] + "' Order by cpNo ", Global.conStrDatabase);
                }
                else if (carrStatus.Length == 1)
                {
                    dTable = getConn.GetAdapterDatatable("SELECT cpCode, cpDate, cpNo,csShortName,pjName, cpComplaint, cpMobile, cpSev, cpCompBy, cpStatus FROM complaint,customermaster,project WHERE cpDel='R' and cpCustomer=csCode and cpProject=pjCode and (cpCustomer='" + cmbCustomer.SelectedValue + "' or 'ALL'='" + cmbCustomer.SelectedValue + "') and cpSev='" + cmbSev.SelectedItem + "' and cpDate between '" + cFDate + "' and '" + cTDate + "' and cpStatus='" + carrStatus[0] + "' Order by cpNo ", Global.conStrDatabase);
                }
                for (int ni = 0; ni < dTable.Rows.Count; ni++)
                {
                    tRow = new TableRow();

                    tCell = new TableCell();
                    tRow.Cells.Add(tCell);

                    tCell = new TableCell();
                    tRow.Cells.Add(tCell);

                    tCell = new TableCell();
                    tRow.Cells.Add(tCell);

                    tCell = new TableCell();
                    tRow.Cells.Add(tCell);

                    tCell = new TableCell();
                    tRow.Cells.Add(tCell);

                    tCell = new TableCell();
                    tRow.Cells.Add(tCell);

                    tCell = new TableCell();
                    tRow.Cells.Add(tCell);

                    tCell = new TableCell();
                    tRow.Cells.Add(tCell);

                    tCell = new TableCell();
                    tRow.Cells.Add(tCell);

                    tCell = new TableCell();
                    tRow.Cells.Add(tCell);

                    if (dTable.Rows[ni]["cpDate"].ToString() != "")
                    {
                        tRow.Cells[0].Text = DateTime.Parse(dTable.Rows[ni]["cpDate"].ToString()).ToString("dd/MM/yyyy");
                    }
                    tRow.Cells[1].Text = dTable.Rows[ni]["cpNo"].ToString();
                    tRow.Cells[2].Text = dTable.Rows[ni]["cpComplaint"].ToString();
                    tRow.Cells[3].Text = dTable.Rows[ni]["cpMobile"].ToString();
                    tRow.Cells[4].Text = dTable.Rows[ni]["cpCompBy"].ToString();
                    tRow.Cells[5].Text = dTable.Rows[ni]["csShortName"].ToString();
                    tRow.Cells[6].Text = dTable.Rows[ni]["pjName"].ToString();
                    tRow.Cells[7].Text = dTable.Rows[ni]["cpSev"].ToString();
                    tRow.Cells[8].Text = dTable.Rows[ni]["cpStatus"].ToString();
                    tRow.Cells[9].Text = "<a href='../Reports/rptComplaint.aspx?CId=WD" + dTable.Rows[ni]["cpCode"].ToString() + "&RequestId=" + cRequestId + "&FromDate=" + cFDate + " > View </a>";
                    dispTable.Rows.Add(tRow);
                }

            }
        }

1 个答案:

答案 0 :(得分:1)

chbStatuslist.Items.Count是否有预期的数字?

dTable.Rows.Count是否有预期的数字?

如果为每个dTable.Rows[ni]["cpNo"].ToString();设置断点,你会看到你想要的断点吗?

您是否收到任何javascript错误?

你能看一下返回浏览器的请求(例如 CTRL + SHIFT + I ,然后是网络标签)看到发送的预期数据?