Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   DataGrid and custom buttons (http://www.velocityreviews.com/forums/t73285-datagrid-and-custom-buttons.html)

ool 02-17-2004 10:47 AM

DataGrid and custom buttons
 
Hello,

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
GridItem)((e.Item))).DataItem)))).Row.ItemArray[1].ToString();
if ( sMyString="Certain Value")
{
System.Web.UI.WebControls.Button bt = new
System.Web.UI.WebControls.Button();
bt.Click +=new EventHandler(this.bt_Click);
bt.Text="My Text";
e.Item.Cells[3].Controls.Add(bt);
}
}
}

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.

Regards

Tomasz




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.