Hi all
Environment: win7
+ VB2010
I'm doing some
tests with the RowDataBound event
of the GridView
in asp.net
What I would
try to do is to iterate all the rows
of the grid that contain data
( no header, no footer) and do two things:
1) add a
mouseover event for each row
2) put the
bold for the second cell in the row
this is the vb code in gv_RowDataBound:
If e.Row.RowType = DataControlRowType.DataRow Then
For Each gr As GridViewRow In gv.Rows
CType(gr.FindControl("lblItemType"), Label).Text = e.Row.RowType.ToString
e.Row.Cells(1).Text = "" & e.Row.Cells(1).Text & ""
Dim cell As String = gr.Cells(1).Text
cell = "'" & "event from GridView " & cell & "'"
gr.Attributes.Add("onmouseover", "Display(" & cell & ")")
gr.Attributes.Add("onmouseout", "Display('')")
Next
End If
and this is the result
as you can see
in the first line does not have the
bold
nell'utima line
and do not have the mouseover
where am I wrong?
thanks
Charles
If you want using for each, use databound event instead RowDataBound.
Rowdatabound is called for every row. You need to remove the loop that you have.
Very thanks
Very thanks
沒有留言:
張貼留言