il metodo SetRenderMethodDelegate, ha come argomento un delegate.
in c# la sintassi č:
e.Row.SetRenderMethodDelegate(CreaIntestazione);
dove CreaIntestazione č il puntatore (indirizzo) della funzione
Purtroppo in basic la sintassi č prolissa:
e.Row.SetRenderMethodDelegate(AddressOf CreaIntestazione)
la traduzione, se sei ancora interessato č:
codice:<%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) libreria.DataBind(Me.GridView1, MioModulo.StringaConnessioneTest, "SELECT * FROM REGIONI ORDER BY NOME_REGIONE", New String() {"codice_istat_regione"}) End Sub Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) If (e.Row.RowType = DataControlRowType.Header) Then e.Row.SetRenderMethodDelegate(AddressOf CreaIntestazione) End If End Sub Private Sub CreaIntestazione(ByVal writer As HtmlTextWriter, ByVal ctl As Control) '//non c'č bisogno di <tr> perchč il writer lo mette in automatico writer.Write("<td colspan=""2"" align=""center"" style=""color:darkblue;background-color:#99ccff"" >CAMPI</td>") writer.Write("</tr>") Me.GridView1.HeaderStyle.AddAttributesToRender(writer) '//ricostruisco la testata originale generata da gridwiew writer.RenderBeginTag("tr") Dim ind As Integer = 0 Do While (ind <= ctl.Controls.Count - 1) ctl.Controls(ind).RenderControl(writer) ind += 1 Loop '//non c'č bisogno della chiusura </tr> perchč il writer lo mette in automatico End Sub </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Pagina senza titolo</title> </head> <body> <form id="form1" runat="server"> <asp:GridView ID="GridView1" runat="server" EnableViewState="false" CellPadding="4" ForeColor="#333333" GridLines="None" OnRowCreated="GridView1_RowCreated"> <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> <EditRowStyle BackColor="#999999" /> <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /> <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> </asp:GridView> </form> </body> </html>

Rispondi quotando