设置 OnItemCreated="ItemCreated"Protected Sub ItemCreated(Sender As Object, e As DataGridItemEventArgs)if e.Item.ItemType=ListItemType.Header then Dim i as Integer Dim widths() As String = {1000, 80, 120, 100, 100, 50, 150} For i = 0 To e.Item.Cells.Count - 1 e.Item.Cells(i).Width = Unit.Parse(widths(i)) Nextend if End Sub
Dim i as Integer
Dim widths() As String = {1000, 80, 120, 100, 100, 50, 150}
For i = 0 To e.Item.Cells.Count - 1
e.Item.Cells(i).Width = Unit.Parse(widths(i))
Nextend if
End Sub
<ItemTemplate>
<asp:label Text='<%# container.dataitem("mcontent") %>' Width=210 Runat=server ID="Label1"/>
</ItemTemplate>
</asp:TemplateColumn>上边的 width 属性就是其宽度
[C#]
private void setwidth()
{
string[] arr=new string[4]{"20","85","125","580"};
for (int i=0;i<MyDataGrid.Columns.Count;i++)
{
MyDataGrid.Columns[i].ItemStyle.Width=Unit.Parse(arr[i].ToString());
}
}不知道你的为什么不行!其他的都没有什么设置
[email protected]结果定义的宽度失效了怎么办啊!?
采用qiushuiwuhen(秋水无恨)上面的方法和后来提供的方法:
style="word-wrap:break-word;"问题解决。