Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: Click event of button control on a tablecell of asp.net Table

Reply
Thread Tools

Re: Click event of button control on a tablecell of asp.net Table

 
 
Svein Terje Gaup
Guest
Posts: n/a
 
      09-15-2004
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
control:
http://msdn.microsoft.com/library/de...mmandtopic.asp

Not sure if this helps,

Sincerely
Svein Terje Gaup

"Bharat Gadhia via .NET 247" <> wrote in message
news:...
(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[0].Columns)
{
TableRow trow = new TableRow();
TableCell tcellcolname;

tcellcolname = new TableCell();
tcellcolname.Text = dc.ColumnName;
trow.BackColor = System.Drawing.Color.Beige;
tcellcolname.BackColor = System.Drawing.Color.AliceBlue;
//add column name to row
tcellcolname.Controls.Add(new LiteralControl(dc.ColumnName.ToString()));
trow.Cells.Add(tcellcolname);

TableCell tcellcoData;
//count the nr of columns to be added as rows
int cnt = ds.Tables[0].Columns.Count;
//loop over rows in table
foreach(DataRow dr in ds.Tables[0].Rows)
{
tcellcoData = new TableCell();
//add column content to row
tcellcoData.Controls.Add(new LiteralControl(dr[dc.ColumnName].ToString()));
trow.Cells.Add(tcellcoData);
counter++;
//after last row(column) add button
if(cnt == counter)
{
btn.ID="btnViewDetails";
btn.Font.Bold=true;
btn.Text="ViewDetails";

TableCell tcellcoData1 = new TableCell();
tcellcoData.Controls.Add(btn);
trow.Cells.Add(tcellcoData1);
}
}
//add each row to the table
DocItemTable.Rows.Add(trow);
}

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/)

<Id>pTfno1+p80WvlmR5b/rRyA==</Id>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
image button click event fires before click event of button Purvi T ASP .Net 0 10-19-2004 06:19 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net Building Controls 1 05-28-2004 06:23 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net 2 05-25-2004 11:45 PM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net Datagrid Control 0 05-25-2004 01:45 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net Web Controls 0 05-25-2004 01:45 AM



Advertisments