473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Dynamic eventhandler

In the following code I'm making a list of links.
When you click a link I want an event to be raised. I have inserted
the Event-code in the bottom of this mail.

When I click a link a postback is made, but the method
lnkShowList_Click is ignored. What do I do wrong?
TableRow tblRow;
TableCell tblCell;
HtmlAnchor link;

foreach(DataRow row in ds.Tables[0].Rows)
{
tblRow = new TableRow();
tblCell = new TableCell();
link = new HtmlAnchor();
link.InnerText = row["CategoryName"].ToString();
link.ID = guidSubCategory;
link.ServerClick += new System.EventHandler(this.lnkShowList_Click);
tblCell.Controls.Add(link);
tblRow.Cells.Add(tblCell);
tblFaqList.Rows.Add(tblRow);
}


Event method:

private void lnkShowList_Click(object sender, EventArgs e)
{
Trace.Warn("test","Test");
}
Nov 18 '05 #1
1 1262
Hi

Try to use LinkButton instead of HtmlAnchor

"Jacob" <je*@dlg.dk> wrote in message
news:5b**************************@posting.google.c om...
In the following code I'm making a list of links.
When you click a link I want an event to be raised. I have inserted
the Event-code in the bottom of this mail.

When I click a link a postback is made, but the method
lnkShowList_Click is ignored. What do I do wrong?
TableRow tblRow;
TableCell tblCell;
HtmlAnchor link;

foreach(DataRow row in ds.Tables[0].Rows)
{
tblRow = new TableRow();
tblCell = new TableCell();
link = new HtmlAnchor();
link.InnerText = row["CategoryName"].ToString();
link.ID = guidSubCategory;
link.ServerClick += new System.EventHandler(this.lnkShowList_Click);
tblCell.Controls.Add(link);
tblRow.Cells.Add(tblCell);
tblFaqList.Rows.Add(tblRow);
}


Event method:

private void lnkShowList_Click(object sender, EventArgs e)
{
Trace.Warn("test","Test");
}

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Bil Muh | last post by:
Esteemede Developers, I would like to Thank All of You in advance for your sincere guidances. I am developing a software using Visual C++ .NET Standard Edition with Windows Form (.NET)...
1
by: Martin Falta | last post by:
Hi all, I need a help with following problem. I need to create a menu from dynamic loaded assembly on the main form of my application. The menu is created succesfully, but the events of this...
9
by: wASP | last post by:
Hello again to all of you geniuses, I'm having a problem trying to load dynamic controls at the initialization phase. I've read the docs, and I thought I had it figured out:...
3
by: RSB | last post by:
Hi Every one Having tuff time creating web controls Dynamically. All i am trying to do is read a table and generate a list of ASP TEXT Box. So how do i create this Control dynamically and where...
5
by: Irfan Akram | last post by:
Hi Mr.Steve, First of all many thanks for your kind response. The thing is that I am trying to control the user's action of deselecting a checkbox, once he has selected it. Also the checkbox has...
5
by: mytestemailaccount | last post by:
Hi, Hope you can help. I am relatively new to all this but would appreciate the groups help. The scenario: I am c# and asp.net to create a web application. The web page contains a user...
4
by: EvelynAnd Ethan | last post by:
Hi, ItemCommand event not firing from a dynamic user control ,WHERE A DATAGRID HAS BUTTON,when i click on the linkbutton first time the itemcommand event doesnt fire,second time event fires up ...
0
by: pjr | last post by:
Using VS2005, I dynamically create an event delegate. Code follows question. My method gets the event's parameters and passes them onto a common event handler. My delegate gets called when expected...
1
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.