you only need to set it once in OnItemCreated event handler and use absolute width like "100px" and set the widths on all columns
解决方案 »
- TreeList控件怎么更新数据到数据库中
- 在服务器上装vss2005里一直报:Internet Information Services (IIS) is not running on this computer
- html代码写进access并读出的几个问题
- 关于"网站访问统计"的问题
- |M| SQL更新语句:提示:子查询返回多于一个。当子... 这种情况是不允许的
- 网页竞拍时,时时显示当前持有者信息,怎样共享???
- 数据格式问题?
- web 想在gridview中添加ms chart控件怎么做
- 关于wise for .net 制作按装得问题
- 如何卸载.net框架集
- 请问那里可以下载vss6.0c
- aspx不支持<script src="html.js"></script>么?
I rewrite my code like this...public void SetColumn_OnItemCreated(object sender, DataGridItemEventArgs e)
{e.Item.Cells[0].Width=100;}But I still can not set anything...thx
否则它还是会自动调整一般的表也是这样
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat="server" language="C#">
void Page_Load(Object sender, EventArgs e)
{
if(!IsPostBack)
{
SqlDataAdapter da = new SqlDataAdapter("select * from authors; select count(*) from authors",
"Server=localhost;Database=pubs;UID=sa;PWD=;");
DataSet ds = new DataSet();
da.Fill(ds,1,2,"authors"); MyDataGrid.DataSource = ds.Tables["authors"].DefaultView;
MyDataGrid.DataBind();
}
} public void ItemCreated(Object sender, DataGridItemEventArgs e)
{ ListItemType itemType = e.Item.ItemType;
if (itemType == ListItemType.Header)
{
for (int i=0; i < e.Item.Cells.Count; i++)
{
e.Item.Cells[i].Width = Unit.Pixel(100);
e.Item.Cells[i].Wrap = false;
}
}
}</script>
<form runat="server">
<asp:DataGrid id="MyDataGrid" runat="server" OnItemCreated="ItemCreated" />
</form>
我明白了,其实是因为我cell的内容过长把单元格撑大了
saucer开始的方法没问题
关键是我没有在HTML页的datagrid的style中写word-wrap:break-word截断英文单词问题已解决,多谢上面几位.
晚安!