Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Making CheckBox in the GridView editable
Message
General information
Forum:
ASP.NET
Category:
Other
Environment versions
OS:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01310520
Message ID:
01310538
Views:
5
This message has been marked as a message which has helped to the initial question of the thread.
>Hi everybody,
>
>I looked through several links but I'm still not clear as how to make the CheckBox field in a GridView to be easily clickable. In my current view it is
>
>
><asp:CheckBoxField DataField="Approved" HeaderText="Approved" SortExpression="Approved" />
which makes it readonly.
>
>I need to be able to simply click on this checkbox. Do you know how can I set up this field in a GridView?
>

Wrap a checkbox control in a template field. How you deal with the user checking/unchecking items depends on how you are planning on updating your data (eg. will it happen immediately when they check/uncheck it, or do they have to click on a "Submit" type button to save the changes).

If it's the second open you'll iterate over the grid, find the checkbox controls, compare against your data and update accordingly.

If it's the first, it gets a bit more complicated because you need to "attach" a value to the control so you know which row is firing the event (unfortunately it doesn't have a CommandName/CommandArgument which would make it easier). You can do things like set it in the Text property and attach a style to hide the text, or I think you can manually add a custom attribute as each checkbox is being databound in the grid using Checkbox.InputAttributes.Add() (using FindControl to get a reference to the checkbox).
-Paul

RCS Solutions, Inc.
Blog
Twitter
Previous
Reply
Map
View

Click here to load this message in the networking platform