我有一个Radgrid谁有动态数据绑定字段来自数据库查询,每次它们是不同的。现在,当此数据显示在GRID上时,我想更改其0为"或"的单元格值。"
谢谢
你需要钩入CellFormatting事件。在这里,您可以检查单元格的值,并根据需要更改它。
类似以下语句的内容:
Private Sub RadGrid_CellFormatting(sender As Object, e As CellFormattingEventArgs) Handles RadGrid.CellFormatting
if e.CellElement.RowInfo.Cells("ZeroColumn").Value = "0" then
e.CellElement.RowInfo.Cells("ZeroColumn").Value = "."
end if
End Sub
try
{
if (e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[e.Row.Cells.Count - 1].Visible = false;
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
for (int i = 3; i < e.Row.Cells.Count; ++i)
{
TextBox tb = new TextBox();
tb.ID = "txtRow" + e.Row.RowIndex.ToString() + "Column" + i.ToString();
tb.Width = 50;
//if (Convert.ToBoolean(e.Row.Cells[i].Text) == false)
//tb.Text = "0";
//tb.Text = e.Row.Cells[i].Text;
e.Row.Cells[i].Controls.Add(tb);
// e.Row.Cells[i].Enabled = Convert.ToBoolean(e.Row.Cells[i].Text);
}
e.Row.Cells[e.Row.Cells.Count - 1].Visible = false;
}
}
catch (Exception ex)
{ }