WebControl

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am developing a WebControl derived from a GridView

As to make to codify the RowDataBound event of the GridView in the WebControl?
 
Are you are trying to handle the RowDataDound event?

If yes then the way I prefer is:

'gridview declared withevents.
Private WithEvents gv As GridView

Private Sub gv_RowDataBound(ByVal s As Object, ByVal e As
GridViewRowEventArgs) Handles gv.RowDataBound
'Handle gv's row data event here.
End Sub

Regards.
 
The code below did not function.

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Text
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls


Public Class WebGridView
Inherits System.Web.UI.WebControls.GridView

Public WithEvents gv As GridView

Public Sub gv_RowDataBound(ByVal s As Object, ByVal e As
GridViewRowEventArgs) Handles gv.RowDataBound
e.Row.Attributes.Add("onclick", "alert('leandro')")
End Sub

End Class
 
I decided with code below


public class WebGridView : System.Web.UI.WebControls.GridView
{
protected override void onRowDataBound(GridViewRowEventArgs e)
{
base.OnRowDataBound(e);
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseout",
"this.style.backgroundColor='white'");
e.Row.Attributes.Add("onmouseover",
"this.style.backgroundColor='#D7D8B8'");
e.Row.Attributes.Add("style", "cursor:hand");
}
}

}
 
Back
Top