473,387 Members | 1,364 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.

Firing An Event From a (Button) Template Column

I'd created a Template column on my datagrid which
contains a textbox and a button that is shown while on
Edit mode. How do I capture the button's click event? It
is not like the pre-built ones (Edit, Update, Cancel and
Delete Button Columns). It seems of being invisible to the
app.

Thanks in advance!
Nov 15 '05 #1
1 4830
Well it sounds like you are using an older version of the .Net framework (datagrid?).
I have a solution if you are using .Net 2.0 framework. By using DatagridViews.

I'm not sure if you can use this sample code, but anything goes.

1. First Make a datagridview caled Test
2. Select the CellClick event property of the datagridview
3. Put this code in your event function

if (e.ColumnIndex == somebuttoncolumn.Index)
{
MessageBox.Show("It works");
}

4. Check current Column index is equal to the index of the column name which in
this case is somebuttoncolumn.
5. Thats it.

Example
private void dataGridView_Test_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == Column_Update_Stock.Index)
{
MessageBox.Show("It works");
}
}
Please tell me if it worked.
Jul 25 '06 #2

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

Similar topics

2
by: Andy Sutorius via DotNetMonster.com | last post by:
Hi, I have a delete button in the item template of my datagrid, when I click it the function for the Insert button is executed instead of the delete button. When I step through in debug, the...
28
by: Tim_Mac | last post by:
hi, i'm new to .net 2.0, and am just starting to get to grips with the gridview. my page has autoEventWireUp set to true, which i gather is supposed to figure out which handlers to invoke when...
6
by: John Smith | last post by:
How can I find out which control performed PostBack? I have put this code inside my Page_Load event: Response.Write(Page.Request.Params.Get("__EVENTTARGET")) but it doesn't write to response...
6
by: Kevin Attard | last post by:
I am using a GridView inside a UserControl which has a template column for deleting the rows. Before databinding the gridview i am attaching the RowCommand and RowDataBound event. I am using the...
13
by: AG | last post by:
I have a gridview that I bind to a List(of Type) at runtime. Not using a datasource control. The gridview has a template column with an imagebutton whose commandname is set to 'Delete'. The...
0
by: Andy | last post by:
Probably this quesion was already raised, but I couldn't find any answer to it, even on Google. My question is: I have a plain datagrid on a page, and I'm adding a button column to it. When...
3
by: =?Utf-8?B?SmFtZXMgTGVubm9u?= | last post by:
I have a gridview that has a button column and a template column with another button in it. When I click on the button column button I can get the row index in the event handler for the...
1
by: Andrew Jocelyn | last post by:
Hi I have a Formview control in a UserControl. The server-side validation is not working, i.e. the events are not firing when a button control which causes validation is fired or even when...
1
by: Forumtroll | last post by:
I have a Web User Control that parses an XML file and renders a Form based on the XML. The problem is that I create a button on the bottom of the form that will fire off a subscribeable event, but...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.