Delegate event
i Usercontrol
public partial class UserControls_Felles_Grid : SatsUserControlBase
{
public delegate void RowDataBound(object sender, GridViewRowEventArgs e);
public event RowDataBound GridRowDataBound;protected void gridview_RowDataBound(object sender, GridViewRowEventArgs e)
{
OnRowDataBound(e);
}
protected void OnRowDataBound(GridViewRowEventArgs e)
{
if (GridRowDataBound != null)
GridRowDataBound(this, e);
}....
}
i side som benytter usercontrol
.aspx
<%@ Page Language="C#" CodeFile="Hendelser.aspx.cs" Inherits="Hendelseside" Title="Hendelser" %>
<%@ Register Src="~/UserControls/Felles/Grid.ascx" TagName="Grid" TagPrefix="uc" %>
<asp:Content ID="MainContent" ContentPlaceHolderID="hovedInnhold" runat="server">
<table>
<tbody>
<tr>
<td>
<uc:Grid ID="gv" runat="server" />
</td>
</tr>
...</asp:Content />
.cs
protected override void OnInit(EventArgs e)
{gv.GridRowDataBound += new UserControls_Felles_Grid.RowDataBound(gv_GridRowDataBound);
}
void gv_GridRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView rad = e.Row.DataItem as DataRowView;
// HendelseinformasjonID
TableCell cell = e.Row.Cells[gv.Kolonner["HendelseInformasjonID"].Indeks];
string HendelseID = cell.Text;cell.ToolTip = rad["Beskrivelse"];
....
Posted by email from Henris blogg (posterous)
No comments :
Post a Comment