473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

DataGrid and custom buttons

ool
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
Nov 18 '05 #1
0 1303

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the...
1
by: Stanley J Mroczek | last post by:
I am trying to load a dropdownlist in VB when the edit is clicked in a datagrid. How do i call Sub loaddd to load the dropdownlist <asp:TemplateColumn runat="server" HeaderText="Id Type Option"...
1
by: Robert Neville | last post by:
I am having some trouble with some old code revolving around custom form navigation buttons. My main form has a sub-form with these custom navigation buttons. In other words, the code should be...
5
by: Phil Townsend | last post by:
I need to add a button to a datagrid. I have tried using the ButtonColumn and have also tried adding a button to a templatecolumn > itemtemplate. Whatever I have tried doesn't work, nor does it...
0
by: Flare | last post by:
I need to assign 2 ordanary buttons as the "show next 10 records" buttons wich a Datagrid by default by it self provide. Is it possible, without totally rewriting the datagrid control? Kindly...
1
by: Jay | last post by:
I need to validate 21 sets of radio buttons before submission to the server for calculation and storage. Is it best to validate on the client side using javascript or to validate on the server...
2
by: Lerp | last post by:
Hi all, I have several template columns in my datagrid, is there an attribute that sets the fore color for the text in these buttons...I would like them to be black instead of the default link...
1
by: Pat | last post by:
Hi all: I have a custom datagrid that has a row of buttons in its header (it serves as a toolbar). I'm overriding the OnBubbleEvent to handle the clicks for these child buttons. However,...
4
by: Daniel | last post by:
Hi All, I need to change the "1 2 3 4..." link button page browsing to 2 buttons which are "<" button and ">" button. is it possible? any guidelines? your help will be appreciated. thank...
1
by: Jeremy Jones | last post by:
is there a way to get both the nav buttons of next and previous, as well as the numeric buttons?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.