I have a query that pulls values from a table in MS Access
SELECT
tblInstructor.InstructorID,
tblInstructor.Football AS InstructorRole,
tblInstructor.Gym AS InstructorRole,
tblInstructor.Yoga AS InstructorRole
FROM
tblInstructor
WHERE
tblInstructor.InstructorID = @InstructID
OR tblInstructorRole.Football = 1
OR tblInstructorRole.Gym = 1
OR tblInstructor.Yoga = 1
Then I do data binding to gridview
On my aspx page, I use the following method to build columns in gridview
<asp:TemplateField HeaderText="Instructor ID">
<ItemTemplate >
<asp:Label ID="lblInstructorID" runat="server" Text='<%# Eval("InstructorID") %>' >
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
I had a problem here when I get an error with several returned data, however, each teacher has only one role, so I'm trying to get the role of an instructor, i.e. depending on whether this is true using my SQL statement above and then set the instructor role column with the instructor role
<asp:TemplateField HeaderText="Instructor Role">
<ItemTemplate >
<asp:Label ID="lblInstructRole" runat="server" Text='<%# Eval("InstructorRole") %>' >
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
3 . , , , / . ( ) InstructorRole gridview, i.e.Football
:
If myReader(3) = True then
Dim Role1 As String = DataBinder.Eval(e.Item.DataItem,"InstructorRole")
Role1 = "Football"
elseif myReader(4) = true then
Dim Role2 As String = DataBinder.Eval(e.Item.DataItem,"InstructorRole")
Role1 = "Gym"
- , , .