我的页面上有这个代码:
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
答案 0 :(得分:0)
检查数据库中的值,并根据该值返回单元格中的任何内容。
TableCell cell5 = new TableCell();
cell5.Text = rowData.GetString(rowData.GetOrdinal("status")).ToString() == "0" ? "Pending" : "Done";