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

Disable RowSelectorColumn checkbox

I'm using Andy Smith's RowSelectorColumn control (great control) and I'm not
sure if this question is generic to all datagrid controls or this particular
one.

Is there a way to disable one of the checkboxes based on data in the grid?
If so, can you provide the syntax?

Thanks,
Chip
Nov 18 '05 #1
1 1568
> I'm using Andy Smith's RowSelectorColumn control (great control) and I'm
not
sure if this question is generic to all datagrid controls or this particular one.

Is there a way to disable one of the checkboxes based on data in the grid? If so, can you provide the syntax?


If you need to take some action for a DataGrid based on the data in the
row, you need to create an event handler for the DataGrid's ItemDataBound
event. There you can check the data, programmatically reference the
checkbox, and then, based on the data, fiddle with the checkbox (or
whatever Web control in the row you're interested in).
** IN THE DATAGRID'S ITEMDATABOUND EVENT HANDLER... **

If e.Item.ItemType = ListItemType.Item or e.Item.ItemType =
ListItemType.AlternatingItem then
'Reference the RowSelectorColumn checkbox (note, it is an
HtmlInputCheckBox class instance,
'and NOT a CheckBox class instance
Dim myCB As HtmlInputCheckBox =
CType(e.Item.Cells(CELLINDEX).Controls(0), HtmlInputCheckBox)

'Check the data
Dim someColumnValue as String = CType(DataBinder.Eval(e.Item.DataItem,
"SomeColumnName"), String)

If someColumnValue = "someValue" then
myCB.Enabled = False
End If
End If

Hope this helps! Also you might find my book, ASP.NET Data Web Controls
Kick Start to be of interest in amassing further knowledge about the
DataGrid, DataList, and Repeater Web controls.

Happy Programming!

--

<shameless plug>
For more information on the DataGrid, DataList, and Repeater controls,
consider picking up a copy of my latest book:

ASP.NET Data Web Controls
http://www.amazon.com/exec/obidos/AS...uysfromrollaco
</shameless plug>

Happy Programming!

Scott Mitchell
mi******@4guysfromrolla.com
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!


Nov 18 '05 #2

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

Similar topics

2
by: HolaGoogle | last post by:
Hi all, Can you please tell me what's wrong with my code??? i do have this database in wich i have to field.One is a "yes/no" field and another one is "number" field. To display the yes/no field...
5
by: Bob Bedford | last post by:
I create checkboxes using datas from a database (with PHP). I store all values in an array, as I must pass this value like a Form value. Now, in some cases, when a checkbox is selected, I must...
1
by: Chip | last post by:
Andy Smith's control (metabuilders.com/Tools/RowSelectorColumn.aspx ) is everywhere and I'm feeling pretty stupid. I've placed the dll in my /bin directory, registered the control, added the column...
0
by: tshad | last post by:
I have been using Andys RowSelectorColumn control for awhile now and it works great. I now need a way to put a button on a datalist datalistitem (as opposed to a datagriditem). The problem is...
4
by: Matrixreloadedth | last post by:
How to change disable color of Checkbox??? I have a checkbox with forecolor in red but when i disable by set Enable properties to false forecolor is changed to gray color but i don't want it. how...
2
by: Kevin | last post by:
I've been looking all over and I can't seem to find what ought to be simple. I need to disable a drop down when a checkbox is checked, and enable it when same checkbox is unchecked. I've...
3
w33nie
by: w33nie | last post by:
I want to disable the text boxes, captain_name and captain_email, but only if the radio button, captain_guarantee, has NOT been checked. how do i do this? <form name="formTeamApplication"...
0
by: jlrolin | last post by:
Tearing my hair out over this, and it may be a postback problem of some sort. I have everything displaying, etc. BUT when I click the "Run Process" button, I want to grab the selected checkboxes...
5
by: masterej | last post by:
Developers, Is there any way to disable all checkboxes on a form? I have a form with 160 checkboxes and I want to be able to disable all of them. Is there a way I can do something like this: ...
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: 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
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
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?
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
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,...

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.