Re: Click event of button control on a tablecell of asp.net Table
The problem seems to be that you are trying to catch an event that was
raised from within another control. The Repeater control and the DataList
control has support for catching such events through the ItemCommand event.
This is not provided by the asp table control. There seems to be no way
provided for this purpose; sombody please correct me if I'm wrong.
I suggest you use the Repeater control in stead of the Table control. The
following article explains how to use the ItemCommand event for the Repeater
Not sure if this helps,
Svein Terje Gaup
"Bharat Gadhia via .NET 247" <firstname.lastname@example.org> wrote in message
(Type your message here)
I have an asp.net application. In response to a button(on the form) click
event I create a asp.net table and create rows and column. These rows and
coulmn's data I extract from dataset and fill the contnet of columns and
rows of the table. As I want to have each row vertically displayed, I use
asp.table control instead of DataGrid control. At the end of each row I have
embeded a button control in last column. Code is as follwos:
private void btnRunTcl_Click(object sender, System.EventArgs e)
DataSet ds = Test();
int counter = 0;
//loop over columns in a row
foreach(DataColumn dc in ds.Tables.Columns)
TableRow trow = new TableRow();
tcellcolname = new TableCell();
tcellcolname.Text = dc.ColumnName;
trow.BackColor = System.Drawing.Color.Beige;
tcellcolname.BackColor = System.Drawing.Color.AliceBlue;
//add column name to row
//count the nr of columns to be added as rows
int cnt = ds.Tables.Columns.Count;
//loop over rows in table
foreach(DataRow dr in ds.Tables.Rows)
tcellcoData = new TableCell();
//add column content to row
//after last row(column) add button
if(cnt == counter)
TableCell tcellcoData1 = new TableCell();
//add each row to the table
this.btnExport.Visible = true;
this.btnPrint.Visible = true;
this.lblQryRslt.Visible = true;
I have wired the button click event of this buttone(button named->
btnViewDetails in above code) in InitializeComponent()as follwos:
this.btn.Click +=new System.EventHandler(this.btnViewDetails_Click);
but somehow this button event does not fire up when the table is displyed
and button in the last coulmn is clicked.
Any suggestion as to why this event does not fire up?
I even tried to put above event in "override protected void OnInit(EventArgs
e)", but it does not show any result.
Thanks for any help in advance.
From: Bharat Gadhia
Posted by a user from .NET 247 (http://www.dotnet247.com/)
|All times are GMT. The time now is 11:04 PM.|
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.