473,385 Members | 1,570 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,385 software developers and data experts.

ButtonColumn in a DataGrid

Hi,

I would like to use a buttoncolumn in my datagrid. But I don't want to
enable the click on it on all the rows. I want to enable the button
according to the data specified in another column. First of all is it
possible to do so, and if yes, how can it be done?
Thanks for your help.
JULIEN

Nov 19 '05 #1
2 1325
Yes it can be done.

1) Handle the ItemDataBound event, 2) check for the condition, 3) locate the
button within the item handled by the event, 4) disable the button.

This sample http://www.societopia.net/samples/dataGrid_5c.aspx handles the
ItemDataBound, and changes the attributes of a buttonColumn of type
LinkButton.

To disable the button you can either replace it with a simple literal
control upon DataBinding or change its onClick event to alert the user (using
JavaScript) that no action is available for this selection.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"jm****@hotmail.com" wrote:
Hi,

I would like to use a buttoncolumn in my datagrid. But I don't want to
enable the click on it on all the rows. I want to enable the button
according to the data specified in another column. First of all is it
possible to do so, and if yes, how can it be done?
Thanks for your help.
JULIEN

Nov 19 '05 #2
Button1.Attributes.Add("OnClick", "javascript: return(false);") should also
disable the button. I did not check this code through.

Trevor Benedict R

"Phillip Williams" <Ph**************@webswapp.com> wrote in message
news:B3**********************************@microsof t.com...
Yes it can be done.

1) Handle the ItemDataBound event, 2) check for the condition, 3) locate
the
button within the item handled by the event, 4) disable the button.

This sample http://www.societopia.net/samples/dataGrid_5c.aspx handles the
ItemDataBound, and changes the attributes of a buttonColumn of type
LinkButton.

To disable the button you can either replace it with a simple literal
control upon DataBinding or change its onClick event to alert the user
(using
JavaScript) that no action is available for this selection.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"jm****@hotmail.com" wrote:
Hi,

I would like to use a buttoncolumn in my datagrid. But I don't want to
enable the click on it on all the rows. I want to enable the button
according to the data specified in another column. First of all is it
possible to do so, and if yes, how can it be done?
Thanks for your help.
JULIEN

Nov 19 '05 #3

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

Similar topics

0
by: Jonathan | last post by:
Hi everyone, i am having a problem with some parameters. I got a datagrid with several columns. My first column is hidden and contains a unique ID for a member. My last column is a buttonColumn....
1
by: Lenin Sakthees via .NET 247 | last post by:
Hi all, I am using a datagrid to show values from a SQL table. My problem is, I want to show the details of the each row when the user clicks the 'View details' buttoncolumn. I am able to fire a...
0
by: Jonathan | last post by:
Hi everyone, i am having a problem with some parameters. I got a datagrid with several columns. My first column is hidden and contains a unique ID for a member. My last column is a buttonColumn....
1
by: nipe | last post by:
Hello, I'm having problem with my custom datagrid control can't fire itemcommand event. The fact is that I have to make fully cutom user control so I can't do any scripting to .aspx file. There...
9
by: rn5a | last post by:
A DataGrid is populated with the records existing in a database. Each of the row in this DataGrid has a ButtonColumn. Assume that the DataGrid displays 10 records (i.e. 10 DataGridItems/rows). Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.