我當前的代碼GridView的行距嘗試設置寬度爲上一個GridView行是:無法設置上的RowDataBound
protected void RowDataBound(Object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
foreach (DataControlFieldHeaderCell dcfhc in e.Row.Cells)
{
dcfhc.Width = 100;
}
}
else
{
foreach (DataControlFieldCell dcfc in e.Row.Cells)
{
dcfc.Width = 100;
}
}
}
但是,這只是把所有的寬度默認的!我究竟做錯了什麼?
編輯:我已經試過這個代碼了!
PoolToDBHeaders.DataSource = new DataView(headerTable);
PoolToDBHeaders.DataBind();
foreach (DataControlField dcf in PoolToDBHeaders.Columns)
{
dcf.ItemStyle.Width = 100;
}
PoolToDBHeaders.DataBind();
您的意思是身高?或者也許列寬? – Ben 2010-07-26 18:38:43
列寬,我用代碼編輯,我試圖用來設置也不起作用的列寬。 – 2010-07-26 18:41:57