2009年12月7日星期一

Gridview 設定 不斷行、欄位隱藏、設定欄寬

Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
If e.Row.RowType = DataControlRowType.DataRow Or e.Row.RowType = DataControlRowType.Header Then
'不斷行設定
For i As Integer = 0 To e.Row.Cells.Count - 1
e.Row.Cells(i).Attributes.Add("style", "word-break :keep-all ; word-wrap:keep-all")
Next
'欄位隱藏
e.Row.Cells(1).Visible = False
'設定欄寬
e.Row.Cells(0).Attributes.Add("style", "width:20px")
e.Row.Cells(2).Attributes.Add("style", "width:30px")
e.Row.Cells(3).Attributes.Add("style", "width:90px")
e.Row.Cells(4).Attributes.Add("style", "width:90px")
e.Row.Cells(5).Attributes.Add("style", "width:70px")
e.Row.Cells(6).Attributes.Add("style", "width:150px")
End If
End Sub

沒有留言:

張貼留言