DataGrid只能用Table的形式显示数据。
当然,其中的各个单元格可以包含其他控件,如CheckBox,DropDownList。
不知道你想显示成什么格式?

解决方案 »

  1.   

    大概有下面几种方法吧:
    1、可以指定 BoundColumn 的 DataFormatString,例如:
       DataFormatString="{0:MM/dd/yyyy}"
       其他格式可以参考 String.Format(Formatting Overview/Formatting Types)。
    2、设定 TemplateColumn,这样就可以用其他控件来显示/修改数据;
    3、在 DataGrid_ItemDataBound 来修改显示格式:
    Dim drv As DataRowView
    Dim lit As ListItemTypelit = e.Item.ItemType' Make sure we're not in header or footer
    If lit = ListItemType.Item _
       OrElse lit = ListItemType.AlternatingItem _
       OrElse lit = ListItemType.SelectedItem _
    Then
    ' Get the DataRowView associated with current item
        drv = CType(e.Item.DataItem, DataRowView) ' Formatting cells text...
        e.Item.Cells(0).Text = PublicUtil.FormatSS(drv("integer_filed"))
        e.Item.Cells(2).Text = CType(drv("date_field"), Date).ToString("MM/yyy")    Dim txt As TextBox ' Also can find a control in template column and ...
        txt = e.Item.FindControl("TextBox1")
        txt.Text = "Any format you want"
    End If