正在替换DbDataRecord c#webforms中的值

本文关键字:c#webforms DbDataRecord 替换 | 更新日期: 2023-09-27 18:20:56

我的页面上有以下代码:

 private void populateNewTableRow(DbDataRecord rowData)
        {
            TableRow tr = new TableRow();

            TableCell cell1 = new TableCell();
            RadioButton radioButton = new RadioButton();
            radioButton.ID = rowData.GetInt32(rowData.GetOrdinal("jobId")).ToString();
            radioButton.GroupName = "MaintenanceRecord";
            cell1.Controls.Add(radioButton);
            tr.Cells.Add(cell1);
            TableCell cell2 = new TableCell();
            cell2.Text = rowData.GetInt32(rowData.GetOrdinal("jobId")).ToString();
            tr.Cells.Add(cell2);
            TableCell cell3 = new TableCell();
            cell3.Text = rowData.GetString(rowData.GetOrdinal("odometerReading")).ToString();
            tr.Cells.Add(cell3);
            TableCell cell4 = new TableCell();
            cell4.Text = rowData.GetString(rowData.GetOrdinal("jobDescription")).ToString();
            tr.Cells.Add(cell4);
            TableCell cell5 = new TableCell();
            cell5.Text = rowData.GetString(rowData.GetOrdinal("status")).ToString();// this
            tr.Cells.Add(cell5);

            tbl_MaitenanceRecord.Rows.Add(tr);
        }

我的数据库中this的值只有字符串"0"或"1",如何将值0替换为"挂起",将值1替换为"完成",并将其传递给其cell.Text

正在替换DbDataRecord c#webforms中的值

检查数据库中的值,并在此基础上在单元格中返回所需的值。

TableCell cell5 = new TableCell();
            cell5.Text = rowData.GetString(rowData.GetOrdinal("status")).ToString() == "0" ? "Pending" : "Done";