BedrijfmasterDatagrid.ascx
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="BedrijfMasterDatagrid.ascx.vb" Inherits="Bedrijf.BedrijfMasterDatagrid" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<link href="../../../RSDHome.css" type="text/css" rel="stylesheet" />
</head>
<body>
<table cellspacing="0" cellpadding="0" width="100%">
<tr>
<td><asp:datagrid id="dgBedrijfMaster" AutoGenerateColumns="False" PageSize="50" AllowCustomPaging="True" ShowHeader="false" OnItemDataBound="dgBedrijfMaster_ItemDataBound" runat="server">
<HeaderStyle CssClass="datagridHeader"></HeaderStyle>
<ItemStyle CssClass="datagridRow"></ItemStyle>
<AlternatingItemStyle CssClass="datagridAlternating"></AlternatingItemStyle>
<Columns>
<asp:TemplateColumn HeaderText="KOLOM 1" HeaderStyle-Width="130" ItemStyle-VerticalAlign="Top">
<ItemTemplate>
<asp:Label id="laKolom1" runat="server" Text='<%#Container.DataItem("Kolom1")%>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
</td>
</tr>
</table>
</body>
</html>
Partial Public Class BedrijfMasterDatagrid
Inherits System.Web.UI.UserControl
Public Event ibImageButtonClicked(ByVal sender As Object, ByVal e As ImageClickEventArgs)
Public Sub BEDRIJFMASTERDATAGRID_MAIN_PROC()
'initialise datatable
Dim BedrijfMasterTable As New DataTable
BedrijfMasterTable.Clear()
BedrijfMasterTable.Columns.Clear()
BedrijfMasterTable.Columns.Add("Kolom1", System.Type.GetType("System.String"))
'fill 1 row for placement BedrijfDatagrid
Dim BedrijfMasterRow As DataRow = BedrijfMasterTable.NewRow
BedrijfMasterTable.Rows.Add(BedrijfMasterRow)
'fill datagrid
dgBedrijfMaster.DataSource = BedrijfMasterTable
dgBedrijfMaster.DataBind()
End Sub
Public Sub dgBedrijfMaster_ItemDataBound(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
'creeer bedrijf en plaats binnen datagrid
e.Item.Cells(0).Controls.Add(setBedrijfDatagrid())
End If
End Sub
Private Function setBedrijfDatagrid() As BedrijfDatagrid
'fill machineindeling machine
Dim BedrijfDatagrid As BedrijfDatagrid = LoadControl("~/User controls/BedrijfDatagrid.ascx")
AddHandler BedrijfDatagrid.ibImageButtonClicked, AddressOf ibImageButton_Click
Call BedrijfDatagrid.BEDRIJFDATAGRID_MAIN_PROC()
Return BedrijfDatagrid
End Function
Public Sub ibImageButton_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
RaiseEvent ibImageButtonClicked(sender, e)
End Sub
End Class
BedrijfDatagrid.ascx
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="BedrijfDatagrid.ascx.vb" Inherits="Bedrijf.BedrijfDatagrid" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<link href="../../../RSDHome.css" type="text/css" rel="stylesheet" />
</head>
<body>
<table cellspacing="0" cellpadding="0" width="100%">
<tr>
<td><asp:datagrid id="dgBedrijf" AutoGenerateColumns="False" PageSize="50" AllowCustomPaging="True" OnItemDataBound="dgBedrijf_ItemDataBound" runat="server">
<HeaderStyle CssClass="datagridHeader"></HeaderStyle>
<ItemStyle CssClass="datagridRow"></ItemStyle>
<AlternatingItemStyle CssClass="datagridAlternating"></AlternatingItemStyle>
<Columns>
<asp:TemplateColumn HeaderText="MEDEWERKER NAAM" HeaderStyle-Width="130">
<ItemTemplate>
<!--Medewerker naam -->
<asp:Label id="laMedewerkerNaam" runat="server" Text='<%#Container.DataItem("Medewerker naam")%>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<!--Save/delete (2) -->
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
</td>
</tr>
</table>
</body>
</html>
Partial Public Class BedrijfDatagrid
Inherits System.Web.UI.UserControl
Public Event ibImageButtonClicked(ByVal sender As Object, ByVal e As ImageClickEventArgs)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Public Sub BEDRIJFDATAGRID_MAIN_PROC()
'initialise datatable
Dim BedrijfTable As New DataTable
BedrijfTable.Clear()
BedrijfTable.Columns.Clear()
BedrijfTable.Columns.Add("Medewerker naam", System.Type.GetType("System.String"))
'fill row
Dim BedrijfRow As DataRow = BedrijfTable.NewRow
BedrijfRow.Item("Medewerker naam") = "TEST"
BedrijfTable.Rows.Add(BedrijfRow)
'fill datagrid
dgBedrijf.DataSource = BedrijfTable
dgBedrijf.DataBind()
End Sub
Public Sub dgBedrijf_ItemDataBound(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
'add imagebutton delete
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
e.Item.Cells(1).Controls.Add(setImageButton("DELETE"))
End If
End Sub
Private Function setImageButton(ByVal ACTIE As String) As ImageButton
Dim ibImageButton As New ImageButton
ibImageButton.ImageUrl = "~\Images\Delete.gif"
ibImageButton.ToolTip = "Verwijder medewerker"
ibImageButton.CommandName = "Delete"
ibImageButton.ID = "ibDelete"
ibImageButton.CommandArgument = ACTIE
AddHandler ibImageButton.Click, AddressOf ibImageButton_Click
Return ibImageButton
End Function
Public Sub ibImageButton_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
RaiseEvent ibImageButtonClicked(sender, e)
End Sub
End Class
BedrijfDetail.aspx
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="BedrijfDetail.aspx.vb" Inherits="Bedrijf.BedrijfDetail" %>
<%@ Register TagPrefix="uc1" TagName="BedrijfMasterDatagrid" Src="User controls/BedrijfMasterDatagrid.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<uc1:BedrijfMasterDatagrid id="BedrijfMasterDatagrid" runat="server"></uc1:BedrijfMasterDatagrid>
</div>
</form>
</body>
</html>
Partial Public Class BedrijfDetail
Inherits System.Web.UI.Page
Protected WithEvents BedrijfMasterDatagrid As Global.Bedrijf.BedrijfMasterDatagrid
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Call BedrijfMasterDatagrid.BEDRIJFMASTERDATAGRID_MAIN_PROC()
End Sub
Private Sub ibImageButtonClicked_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles BedrijfMasterDatagrid.ibImageButtonClicked
'THIS EVENT IS NOT FIRED
End Sub
End Class