ASP.NET DataGrid: CheckBox Disabling Based on other Fields

liunx

Guest
if i make a datagrid of excel data, and i put checkboxes beside each row, how do i make the checkbox enable/disable depending on the value of one of the fields?

i'm just a little lost on how to refer to them, since it's all autogenerated

<asp:dataGrid id="data" runat="server">
<HeaderStyle Font-Bold="True"></HeaderStyle>
<Columns>
<asp:TemplateColumn>
<itemtemplate>
<asp:CheckBox EnableViewState="true" id="chkSelect" runat="server">
</asp:CheckBox>
</itemtemplate>
</asp:TemplateColumn>
</Columns>
</asp:dataGrid>Using the OnItemBound event on the control you can use

FindControl that to cast it as a CheckBox, then depending on the data value that was passed in also you can

CheckBox.Checked = (bool)d[""].value;

or something like that. Not tried it with excel and how it handles data.dudes, I so need to get me off to that .NET training.

between having to listen to the programmer next to me rant and rave about who great it is and seeing all these nifty little questions you guys keep bringing up, I'm sooooooo feeling left out of the loop

:Pheh at least you'll GET training

i'm just working off tutorials... and there's not nearly as much around online as there was for regular ASP =/

i should get a book or something.

afterburn: i'm still lost. which control has the OnItemBound property? once that is fired i call a method, use the sender to get the checkbox control, but how would i get the value from the datagrid for that particular row/column?Originally posted by putts
dudes, I so need to get me off to that .NET training.

between having to listen to the programmer next to me rant and rave about who great it is and seeing all these nifty little questions you guys keep bringing up, I'm sooooooo feeling left out of the loop

:P

<!-- m --><a class="postlink" href="http://www.aspnetwebcasts.com">http://www.aspnetwebcasts.com</a><!-- m -->


That site listen to 4 of them recorded or live and get a .net book free with VB.net free.Originally posted by eRad
which control has the OnItemBound property? once that is fired i call a method, use the sender to get the checkbox control, but how would i get the value from the datagrid for that particular row/column?

The datagrid, DataList,Repeater. Not a property an event.

For your knowledge "Code Behind" is not going to be supported much longer. Also found out today that there are filters. yOu can create filters for controls and bind them on different browsers. very cool feature.... dynamically specify the master page that your code page is going to use with them....Unfortunately, we have run out of ASP.NET development books and bonus complimentary CDs. We apologize for the inconvenience. If you registered for the ASP.NET Webcast Series and selected to receive the ASP.NET development books, you should receive your complimentary gift package within 6-8 weeks.

*cries*

BTW all the webcasts are free right? cuz i can i get free copies of VS.NET,windows, and other stuff from my university anywayOriginally posted by afterburn
For your knowledge "Code Behind" is not going to be supported much longer. Also found out today that there are filters. yOu can create filters for controls and bind them on different browsers. very cool feature.... dynamically specify the master page that your code page is going to use with them....

I mentioned that to the guy here who uses .NET and he doesn't believe it.

Can you give me some reference to where MS says Code Behinds are going away?What are code behinds?...lol >_<Originally posted by putts
I mentioned that to the guy here who uses .NET and he doesn't believe it.

Can you give me some reference to where MS says Code Behinds are going away?

Yeah the webcast ASP.net 2.0 Page Level Event strucutre.


Yeah its being removed because VS.net is what ties all that together. Removing the IDE from the compile time to make it work just on the code ....Originally posted by eRad
What are code behinds?...lol >_<

VS.net 2002 and 2003, when creating a webform allows you to place the code of the page in a seperate .cs or .vb file. Which it would combine to one page during compile time. Good to seperate code from HTML and controls on the page.Originally posted by eRad
U
BTW all the webcasts are free right? cuz i can i get free copies of VS.NET,windows, and other stuff from my university anyway

Yes I have listened to 3 of them so far since last week....Originally posted by afterburn
VS.net 2002 and 2003, when creating a webform allows you to place the code of the page in a seperate .cs or .vb file. Which it would combine to one page during compile time. Good to seperate code from HTML and controls on the page.
can't you do that manually anyway? by code you mean the VB/C# scripts right? i always thought you'd just put the code in those source files then reference them like a .js..

o_OCan't do it with the new compiler.....

and not thats not really how it works but something like that ...the 'first look at asp.net 2.0' webcast shows Code Behind as one of the improved features...Yeah but look in detail. The code behinds as it works now is not the same. the IDE handles it. in ASP.net 2.0 it will now be covered by the IL compiler.
 
Back
Top