Hussain Hashimi

Hussain Hashimi

  • NA
  • 8
  • 2.2k

Grid View - Displaying Data-bound Checkbox

Jun 13 2019 5:30 PM
Hi,
 
I am using a grid view on my aspx page.
 
I want to display Field text along with the checkbox.
 
example:
 
There is a database table as follows
 
PatientSymptoms
++++++++++++++++++++
SymptomId (1, 2, 3, ...... N)
SymptomName (Symptom A, Symptom B, ...... Symptom X)
 
A patient will be shown list of symptoms in a grid, he has to select the symptoms which apply to his situation.
 
[ ] Symptom A
[x] Symptom B
[ ] Symptom C
[ ] Symptom D
 
Now, I want to associate, the checkbox with the "SymptomId" field
 
and I can't figure out how.
 
I am using the following code
 
<asp:GridView ID="Symptoms2" runat="server" AutoGenerateColumns="False" CssClass="SymptomsTable">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox runat="server" ID="chkIsTrue2" WhichProperty ='<%# Bind("TYPE_P_ID") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField ReadOnly="true" DataField="Health Concern" HeaderText="Please Select the Symptom that Apply"/> </Columns>
</asp:GridView>
 
Notice that, I can't figure out the property whcih should be associated with the TYPE_P_ID, so I have written WhichProperty for understanding
 
Any comments on what is the better way to do it?
thanks

Answers (6)