Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GridView with Checkboxes and Save button
Message
General information
Forum:
ASP.NET
Category:
Client-side development
Environment versions
Environment:
C# 3.0
OS:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01326379
Message ID:
01326702
Views:
17
>You could create a js function that increments/decrements a global variable i.e. rowsChecked. Add a call to that function to each checkbox onClientClick in your gridview. At the end of the function check the rowsChecked variable and set the Approve button. Something like below (just pseudo-code). Seems like this would be better than looping though all the rows each time you check/unncheck.
>
>I've used Scott's approach in the article for putting a Select All checkbox in a column header. Works well.
>
>function RowCheckCount(state)
>{
>if (state)
>rowsChecked++;
>else
>rowsChecked--;
>
>if rowsChecked > 0
>Approved.enabled = true;
>else
>Approved.enabled = false;
>}


The idea looks good, but where exactly should I put the global var declaration and the function?

I have a master page.

Also I'm having troubles implementing the concept even in the simplified case I tried. In other words, looks like I can not manipulate with the enabled status of the button from both Client and Server sides.


>>Hi everybody,
>>
>>I have a GridView with checkboxes. I also have an Approve button. I want to be able to have the Approve button initially disabled and enable it only after I selected a record in the Grid (if I uncheck it I want the button to become disabled again).
>>
>>Do you think it's hard to implement? Should I try to inject the JavaScript from the server side? The GridView is inside the UpdatePanel.
>>
>>Thanks in advance.
>>
>>Reading this article http://aspnet.4guysfromrolla.com/articles/053106-1.aspx in the meantime.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform