Velocity Reviews

Velocity Reviews (
-   ASP .Net (
-   -   DataGrid and custom buttons (

ool 02-17-2004 10:47 AM

DataGrid and custom buttons

I have a DataGrid with a few columns, I would like to add a column with a
button, which will be displayed only if row contatins certain data.
I also would like to define a special action after clicking on tkis button.

To create a button I used ItemCreated event for DataGrid:

private void DataGrid1_ItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.EditItem)
string sMyString=

((System.Data.DataRowView)(((System.Object)(((Syst em.Web.UI.WebControls.Data
if ( sMyString="Certain Value")
System.Web.UI.WebControls.Button bt = new
bt.Click +=new EventHandler(this.bt_Click);
bt.Text="My Text";

The button is properly created and displayed but Event Handler function
bt_Click is never invoked
private void bt_Click(object sender, EventArgs e)
//My Action


Could someone help me solve this problem? I would be very grateful.



All times are GMT. The time now is 01:17 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.