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:
01326739
Views:
17
This message has been marked as a message which has helped to the initial question of the thread.
You'd have to initially get a count of the rows checked server side. Create a page level variable and increment in the row_databound or loop throught the DataTable and then use that when you're creating the js to set the var's initial value. Use Page.ClientScript or ScriptManager to register the js block.

You should be able to set the button server side in the Page_Load after you determine how many rows are checked.

You would put the var declaration above the function.


>>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.
Regards,

E.R. Gilmore
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform