Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DataGrid and custom buttons

Reply
Thread Tools

DataGrid and custom buttons

 
 
ool
Guest
Posts: n/a
 
      02-17-2004
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


 
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
The Z axis and simple menu buttons/image buttons Jonathan N. Little HTML 3 04-02-2007 09:57 AM
Datagrid Nav buttons and numeric buttons Jeremy Jones ASP .Net 1 03-22-2007 08:00 AM
Dynamically creating buttons in custom datagrid control lawrence ASP .Net Datagrid Control 0 11-18-2003 05:19 PM
How to assign custom buttons to a paging enabled datagrid Flare ASP .Net 0 08-26-2003 05:53 PM
Re: Custom image buttons in Datagrid Srinivasa Reddy K Ganji ASP .Net 0 07-25-2003 08:29 AM



Advertisments