A
Anthony Williams
Hi all,
Before I have a mild breakdown and start throwing computers around, I just
wanted to check to see that I'm not being a colossal idiot and getting
things all mixed up.
Vital Statistics: .NET 1.1, C#, IIS6
I have a repeater (extraneous templates/controls removed for brevity) within
a UserControl:
======================================================================
<asp:Repeater id="rptSuppliers" runat="server">
<ItemTemplate>
<p><asp:LinkButton id="btnEdit" runat="server" text="Edit" /></p>
</ItemTemplate>
</asp:Repeater>
======================================================================
As well as that, I have some C# code:
======================================================================
override protected void Page_Init(object Sender, System.EventArgs e) {
// This code is actually all put in place by VS.NET, but I've just
// taken out the InitializeComponent() bits for brevity...
this.rptSuppliers.ItemDataBound += new
RepeaterItemEventHandler(rptSuppliers_ItemDataBound);
base.OnInit(e);
}
private void Page_Load(object sender, System.EventArgs e) {
if (!this.IsPostBack) {
bindSuppliers();
}
}
private void bindSuppliers() {
System.Data.DataSet ds = new DataSet();
// Code to retrieve dataset contents removed for brevity
rptSuppliers.DataSource = ds.Tables(0);
rptSuppliers.DataBind();
}
private void rptSuppliers_ItemDataBound(object sender,
RepeaterItemEventArgs e) {
switch (e.Item.ItemType) {
case ListItemType.Item:
case ListItemType.AlternatingItem:
LinkButton thisBtnEdit =
(LinkButton)e.Item.FindControl("btnEdit");
thisBtnEdit.Click += new
EventHandler(rptSuppliers_btnEdit_Click);
}
}
private void rptSuppliers_btnEdit_Click(object sender, EventArgs e) {
Trace.Write("Edit button event fired!");
}
======================================================================
For some bizarre reason, the Click event for each Edit button within the
databound repeater does not fire.
Am I doing something wrong?
I don't claim to be a C# expert - I've just started moving to C# from VB.NET
and I'm having fun doing so - except for right now. Please help me to save
my hair and scalp!
Many thanks,
Anthony
Before I have a mild breakdown and start throwing computers around, I just
wanted to check to see that I'm not being a colossal idiot and getting
things all mixed up.
Vital Statistics: .NET 1.1, C#, IIS6
I have a repeater (extraneous templates/controls removed for brevity) within
a UserControl:
======================================================================
<asp:Repeater id="rptSuppliers" runat="server">
<ItemTemplate>
<p><asp:LinkButton id="btnEdit" runat="server" text="Edit" /></p>
</ItemTemplate>
</asp:Repeater>
======================================================================
As well as that, I have some C# code:
======================================================================
override protected void Page_Init(object Sender, System.EventArgs e) {
// This code is actually all put in place by VS.NET, but I've just
// taken out the InitializeComponent() bits for brevity...
this.rptSuppliers.ItemDataBound += new
RepeaterItemEventHandler(rptSuppliers_ItemDataBound);
base.OnInit(e);
}
private void Page_Load(object sender, System.EventArgs e) {
if (!this.IsPostBack) {
bindSuppliers();
}
}
private void bindSuppliers() {
System.Data.DataSet ds = new DataSet();
// Code to retrieve dataset contents removed for brevity
rptSuppliers.DataSource = ds.Tables(0);
rptSuppliers.DataBind();
}
private void rptSuppliers_ItemDataBound(object sender,
RepeaterItemEventArgs e) {
switch (e.Item.ItemType) {
case ListItemType.Item:
case ListItemType.AlternatingItem:
LinkButton thisBtnEdit =
(LinkButton)e.Item.FindControl("btnEdit");
thisBtnEdit.Click += new
EventHandler(rptSuppliers_btnEdit_Click);
}
}
private void rptSuppliers_btnEdit_Click(object sender, EventArgs e) {
Trace.Write("Edit button event fired!");
}
======================================================================
For some bizarre reason, the Click event for each Edit button within the
databound repeater does not fire.
Am I doing something wrong?
I don't claim to be a C# expert - I've just started moving to C# from VB.NET
and I'm having fun doing so - except for right now. Please help me to save
my hair and scalp!
Many thanks,
Anthony