2011-11-24 55 views

回答

-3
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) 
{ } 
+0

答案是不是有幫助,你應該解釋你如何得到答案 – thecoshman

+0

這似乎是一些代碼,將是對radgrid控件OnItemDataBound事件。不確定它的壽命。 –

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 
相關問題