Check box enabled in GridView?

G

Guest

How do you enable a check box in the GridView. I selected Checkbox Field in
the Columns of the GridView, and the check box shows up in the Grid view, but
it is disabled. How do I enable it so I can check/uncheck it. Also, what
event do I use to check it for a value? Any articles out there?
 
K

Ken Cox [Microsoft MVP]

Hi Chris,

Could you show the code that's giving you trouble? Did you happen to set
something as read-only?

Ken
Microsoft MVP [ASP.NET]
 
G

Guest

Here is the code. I tried it two ways. One with a check box field and one
with a template and I dragged a check box over to the GridView. For the Check
box field it is set to read only. The template field lets me check/uncheck,
but There is nowhere to specify the data field. Where do I specify the Data
field with a template field?

Also, I know how to use the old DataGrid, but since the Gridview replaces
DataGrid, and the events are different, what are similar events for
Item_Command and Item_DataBound from the DataGrid, for the GridView? I found
RowCommand and RowDataBound. Are these the same? Do you have some snippets of
code to use to check a cell ie; e.Cells(0).Text like in the data grid to see
what the result of someone checking checkboxes in the GridView? I need code
snippets for DataBound before displaying and also after they check a box. Can
you refer me to some good articles?


<asp:GridView ID="dgApproval" runat="server"
AutoGenerateColumns="False" AllowPaging="True" AllowSorting="True">
<Columns>
<asp:BoundField DataField="Suffix" HeaderText="Suffix" />
<asp:BoundField DataField="FirstName" HeaderText="First
Name" />
<asp:BoundField DataField="LastName" HeaderText="Last
Name" />
<asp:TemplateField HeaderText="Is Approved By Physician
Relations">
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server"
AutoPostBack="True" Text="Approved" />
</ItemTemplate>
</asp:TemplateField>
<asp:CheckBoxField
DataField="IsApprovedByPhysicianRelations" ReadOnly="false" HeaderText="Is
Approved By Physician Relations2" />
<asp:BoundField DataField="MI" HeaderText="MI" />
<asp:BoundField DataField="Practice"
HeaderText="Practice" />
<asp:BoundField DataField="EmailAddress"
HeaderText="Email Address" />
<asp:BoundField DataField="Degree" HeaderText="Degree" />
<asp:BoundField DataField="Phone" HeaderText="Phone" />
<asp:BoundField DataField="Fax" HeaderText="Fax" />
<asp:BoundField DataField="Speciality"
HeaderText="Speciality" />
</Columns>
</asp:GridView>



--
Chris Davoli



Ken Cox said:
Hi Chris,

Could you show the code that's giving you trouble? Did you happen to set
something as read-only?

Ken
Microsoft MVP [ASP.NET]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top