Imports System.Data.OleDb
Imports System.Data
Imports System.Web
Imports System.Web.UI

Partial Class _TakeSurvey Inherits System.Web.UI.Page

Dim sid, query1, query2, query3, query4, query5, query6, qnos, currentQ, q_type, filledby, qid, status1 As String
Dim dbcon As String = "Provider=Microsoft.Jet.OleDb.4.0;" & _
       "Data Source=|DataDirectory|SurveyDatabase.mdb"
Dim con, conn, conn1, conn2 As OleDbConnection
Dim da, da1, da2, da3 As OleDbDataAdapter
Dim ds, ds1, ds2, ds3 As DataSet
Dim cmd As OleDbCommand
Dim firstQ As Boolean
Dim strQs As String()
Dim strQind As String()
Dim i, j, k As Integer
Dim Q_ID As New ArrayList
Dim recordedS As Boolean = False
Dim recordedR As Boolean = False
Private rbl_responses As RadioButtonList
Private rbl_responses1 As RadioButtonList
Dim strAnswer As String
Dim rb As RadioButtonList



Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    If Request("status1") <> "" Then
        status1 = Request("status1").ToString
    End If
    If Request("currentQ") <> "" Then
        currentQ = Request("currentQ").ToString
    End If

    If Request("sid") <> "" Then
        sid = Request("sid").ToString
    End If

    If Request("q_type") <> "" Then
        q_type = Request("q_type").ToString
    End If

    Using conn2 As New Data.OleDb.OleDbConnection(dbcon)

        query4 = "Select * From SatisfactionQs where QuestionNo=" & CInt(currentQ)

        conn2.Open()
        Using cmd As New OleDbCommand(query4, conn2)


            Using sdr4 As OleDbDataReader = cmd.ExecuteReader()

                While sdr4.Read()
                    q_type = sdr4("Choicetype").ToString
                End While

            End Using
        End Using

        conn2.Close()
    End Using

    Using conn As New Data.OleDb.OleDbConnection(dbcon)

        query2 = "Select * From Survey where ID=" & sid

        conn.Open()
        Using cmd As New OleDbCommand(query2, conn)


            Using sdr2 As OleDbDataReader = cmd.ExecuteReader()

                While sdr2.Read()

                    qnos = sdr2("ChosenQs").ToString

                    descrp.Text = sdr2("Description").ToString

                    dt_incident.Text = sdr2("Incidentdate").ToString

                    r_dep.Text = sdr2("Dept").ToString

                    r_sect.Text = sdr2("Sect").ToString

                    r_name.Text = sdr2("Usernm").ToString

                    IT_staff.Text = sdr2("IT_staff").ToString

                    filledby = IT_staff.Text

                End While

            End Using
        End Using

        conn.Close()
    End Using

    strQs = qnos.Split(New Char() {";"c})
    Dim noQs As Integer = strQs.Length - 1




    If Not Page.IsPostBack Then


        If Request("status1") <> "" Then
            status1 = Request("status1").ToString
        End If
        If Request("currentQ") <> "" Then
            currentQ = Request("currentQ").ToString
        End If

        Using conn2 As New Data.OleDb.OleDbConnection(dbcon)

            query6 = "Select * From SatisfactionQs where QuestionNo=" & CInt(currentQ)

            conn2.Open()
            Using cmd As New OleDbCommand(query6, conn2)


                Using sdr4 As OleDbDataReader = cmd.ExecuteReader()

                    While sdr4.Read()
                        q_type = sdr4("Choicetype").ToString
                    End While

                End Using
            End Using

            conn2.Close()
        End Using

        If currentQ = "" And status1 = "" Then
            i = 0
            currentQ = strQs(i)
        Else
            btn_Prev.Visible = True
        End If


        If currentQ = strQs(noQs) Then
            Complete.Enabled = True
            Complete.Visible = True
        End If
        Response.Write("Value of i:" + i.ToString)
        j = i
        Response.Write("Value of j:" + j.ToString)
        If status1 = "next" Then
            If (i < noQs) Then
                i = i + 1
            End If
            currentQ = strQs(i)
            Response.Write(status1)
            Response.Write("No. of Question:" + noQs.ToString)
            Response.Write("i:" + i.ToString)
            Response.Write("currentQ:" + currentQ)
        ElseIf status1 = "previous" Then
            If (j > 0) Then
                j = j - 1
            End If

            currentQ = strQs(j)
            Response.Write(status1)
            Response.Write("No. of Question:" + noQs.ToString)
            Response.Write("j:" + j.ToString)
            Response.Write("currentQ:" + currentQ)
        End If


        Using conn2 As New Data.OleDb.OleDbConnection(dbcon)

            query4 = "Select * From SatisfactionQs where QuestionNo=" & CInt(currentQ)

            conn2.Open()
            Using cmd As New OleDbCommand(query4, conn2)


                Using sdr4 As OleDbDataReader = cmd.ExecuteReader()

                    While sdr4.Read()
                        q_type = sdr4("Choicetype").ToString
                    End While

                End Using
            End Using

            conn2.Close()
        End Using

        Using conn1 As New Data.OleDb.OleDbConnection(dbcon)

            query3 = "Select * From UserResponses where ChoiceType= 'Satisfaction' and QuestionNo=" & CInt(currentQ)

            conn1.Open()
            Using cmd As New OleDbCommand(query3, conn1)


                Using sdr3 As OleDbDataReader = cmd.ExecuteReader()

                    While sdr3.Read()
                        recordedS = True
                    End While

                End Using
            End Using

            conn1.Close()
        End Using

        Using conn3 As New Data.OleDb.OleDbConnection(dbcon)

            query5 = "Select * From UserResponses where ChoiceType= 'Reason' and QuestionNo=" & CInt(currentQ)

            conn3.Open()
            Using cmd As New OleDbCommand(query5, conn3)


                Using sdr3 As OleDbDataReader = cmd.ExecuteReader()

                    While sdr3.Read()
                        recordedR = True
                    End While

                End Using
            End Using

            conn3.Close()
        End Using

        If q_type = "Reason" And recordedR = False And RadioButtonList2.SelectedIndex < 0 Then

            Dim ind_q, q_id As String
            Dim radioList As RadioButtonList = DirectCast(Page.FindControl("RadioButtonList2"), RadioButtonList)
            Using conn2 As New Data.OleDb.OleDbConnection(dbcon)

                query4 = "Select * From SatisfactionQs where QuestionNo=" & CInt(currentQ)
                Response.Write(query4)
                conn2.Open()
                Using cmd As New OleDbCommand(query4, conn2)


                    Using sdr4 As OleDbDataReader = cmd.ExecuteReader()

                        While sdr4.Read()
                            ind_q = sdr4("Individual_Q").ToString
                            q_id = sdr4("Question_ID").ToString
                            radioList.Items.Add(New ListItem(ind_q, q_id))
                        End While

                    End Using
                End Using
                RadioButtonList2.Visible = True
                RadioButtonList1.Visible = False
                conn2.Close()
            End Using
        End If

        If q_type = "Reason" And recordedR = False And RadioButtonList2.SelectedIndex > 0 Then
            Dim Query1, q_no1 As String
            Dim value1 As String
            q_no1 = ""
            RadioButtonList2.Visible = True
            RadioButtonList1.Visible = False
            For i As Integer = 0 To RadioButtonList2.Items.Count - 1
                If RadioButtonList2.Items(i).Selected Then
                    'get the text value of the selected radio button
                    value1 = "1"
                Else
                    value1 = "0"
                End If
                Using conn1 As New Data.OleDb.OleDbConnection(dbcon)
                    Query1 = "Select * From SatisfactionQs where Question_ID=" & CInt(RadioButtonList2.Items(i).Value)
                    conn1.Open()
                    Using cmd1 As New OleDbCommand(Query1, conn1)
                        Using sdr As OleDbDataReader = cmd1.ExecuteReader()
                            While sdr.Read()
                                q_no1 = sdr("QuestionNo").ToString
                            End While
                        End Using
                    End Using
                    conn1.Close()
                End Using
                Query1 = "Insert Into UserResponses (SurveyID, Question_ID, QuestionNo, ChoiceType, RadioChosen, Satisfaction, OtherResponse, FilledBy) Values ('" + sid.ToString + "','" + RadioButtonList2.Items(i).Value.ToString + "','" + q_no1 + "','Reason','" + value1 + "','0', NULL,'" + filledby + "')"
                Response.Write(Query1)
                Using conn1 As New Data.OleDb.OleDbConnection(dbcon)
                    Using cmd As New Data.OleDb.OleDbCommand(Query1, conn1)
                        conn1.Open()
                        Try
                            cmd.ExecuteNonQuery()
                        Catch ex As Exception
                            Literal1.Text = ex.Message
                        End Try
                        conn1.Close()
                    End Using
                End Using
            Next
        End If
        con = New OleDbConnection(dbcon)
        If q_type = "Satisfaction" And recordedS = False Then
            Dim query As String = "SELECT Question_ID, Individual_Q FROM SatisfactionQs where Choicetype='Satisfaction' and QuestionNo=" & CInt(currentQ)
            Dim strAnswer As String
            Dim ds As New DataSet()

            Dim ad As New OleDbDataAdapter(query, con)

            ad.Fill(ds)

            If ds IsNot Nothing Then
                If ds.Tables(0).Rows.Count <> 0 Then
                    GridQuiz.DataSource = ds
                    GridQuiz.DataBind()
                Else
                    GridQuiz.DataSource = Nothing
                    GridQuiz.DataBind()
                End If
            End If



            For Each gvrow As GridViewRow In GridQuiz.Rows

                Dim Query1, q_no1 As String
                q_no1 = ""
                strAnswer = ""

                If DirectCast(gvrow.FindControl("RadioOption1"), RadioButton).Checked = True Then
                    strAnswer = "4"
                    Response.Write("Very Satisfied")
                ElseIf DirectCast(gvrow.FindControl("RadioOption2"), RadioButton).Checked = True Then
                    strAnswer = "3"
                    Response.Write("Satisfied")
                ElseIf DirectCast(gvrow.FindControl("RadioOption3"), RadioButton).Checked = True Then
                    strAnswer = "2"
                    Response.Write("Dissatisfied")
                ElseIf DirectCast(gvrow.FindControl("RadioOption4"), RadioButton).Checked = True Then
                    strAnswer = "1"
                    Response.Write("Very Dissatisfied")
                End If

                Response.Write("strAnswer:" & strAnswer)
                If (strAnswer <> "") Then

                    Dim Q_ID As String = GridQuiz.DataKeys(gvrow.RowIndex).Value

                    Using conn1 As New Data.OleDb.OleDbConnection(dbcon)
                        Query1 = "Select * From SatisfactionQs where Question_ID=" & CInt(Q_ID)
                        conn1.Open()
                        Using cmd1 As New OleDbCommand(Query1, conn1)
                            Using sdr As OleDbDataReader = cmd1.ExecuteReader()
                                While sdr.Read()
                                    q_no1 = sdr("QuestionNo").ToString
                                End While
                            End Using
                        End Using
                        conn1.Close()
                    End Using

                    Query1 = "Insert Into UserResponses (SurveyID, Question_ID, QuestionNo, ChoiceType, RadioChosen, Satisfaction, OtherResponse, FilledBy) Values ('" + sid + "','" + Q_ID + "','" + q_no1 + "','Satisfaction','0','" + strAnswer + "',NULL,'" + filledby + "')"
                    Response.Write(Query1)
                    Using conn1 As New Data.OleDb.OleDbConnection(dbcon)
                        Using cmd As New Data.OleDb.OleDbCommand(Query1, conn1)
                            conn1.Open()
                            Try
                                cmd.ExecuteNonQuery()
                            Catch ex As Exception
                                Literal1.Text = ex.Message
                            End Try
                            conn1.Close()
                        End Using
                    End Using
                End If
            Next
        End If

        If q_type = "Satisfaction" And recordedS = True Then
            Dim q_no As String
            q_no = ""
            Dim strAnswer1, strAnswer2 As String
            strAnswer1 = ""
            strAnswer2 = ""
            Dim query As String = "SELECT UserResponses.Question_ID, UserResponses.Satisfaction, SatisfactionQs.Individual_Q FROM UserResponses INNER JOIN SatisfactionQs ON UserResponses.Question_ID = SatisfactionQs.Question_ID where SatisfactionQs.ChoiceType='Satisfaction' and UserResponses.QuestionNo=" & CInt(currentQ)

            Dim ds As New DataSet()

            Dim ad As New OleDbDataAdapter(query, con)

            ad.Fill(ds)

            If ds IsNot Nothing Then
                If ds.Tables(0).Rows.Count <> 0 Then
                    GridQuiz1.DataSource = ds
                    GridQuiz1.DataBind()
                Else
                    GridQuiz1.DataSource = Nothing
                    GridQuiz1.DataBind()
                End If
            End If

            For Each gvrow1 As GridViewRow In GridQuiz1.Rows
                conn1.Open()
                Using cmd1 As New OleDbCommand(query, conn1)
                    Using sdr As OleDbDataReader = cmd1.ExecuteReader()
                        While sdr.Read()
                            strAnswer2 = sdr("Satisfaction").ToString
                            If strAnswer2 = "4" Then
                                DirectCast(gvrow1.FindControl("RadioOption1"), RadioButton).Checked = True
                            ElseIf strAnswer2 = "3" Then
                                DirectCast(gvrow1.FindControl("RadioOption2"), RadioButton).Checked = True
                            ElseIf strAnswer2 = "2" Then
                                DirectCast(gvrow1.FindControl("RadioOption3"), RadioButton).Checked = True
                            ElseIf strAnswer2 = "1" Then
                                DirectCast(gvrow1.FindControl("RadioOption4"), RadioButton).Checked = True
                            End If
                        End While
                    End Using
                End Using
                conn1.Close()
            Next


            For Each gvrow1 As GridViewRow In GridQuiz1.Rows

                If DirectCast(gvrow1.FindControl("RadioOption1"), RadioButton).Checked = True Then
                    strAnswer1 = "4"
                End If
                If DirectCast(gvrow1.FindControl("RadioOption2"), RadioButton).Checked = True Then
                    strAnswer1 = "3"
                End If
                If DirectCast(gvrow1.FindControl("RadioOption3"), RadioButton).Checked = True Then
                    strAnswer1 = "2"
                End If
                If DirectCast(gvrow1.FindControl("RadioOption4"), RadioButton).Checked = True Then
                    strAnswer1 = "1"
                End If
                Response.Write(strAnswer1)
                Dim Q_ID As String = GridQuiz1.DataKeys(gvrow1.RowIndex).Value

                Response.Write("Question ID:" & Q_ID & "<br>")
                Using conn1 As New Data.OleDb.OleDbConnection(dbcon)
                    query1 = "Select * From SatisfactionQs where Question_ID=" & CInt(Q_ID)
                    conn1.Open()
                    Using cmd1 As New OleDbCommand(query1, conn1)
                        Using sdr As OleDbDataReader = cmd1.ExecuteReader()
                            While sdr.Read()
                                q_no = sdr("QuestionNo").ToString
                            End While
                        End Using
                    End Using
                    conn1.Close()
                End Using
                query5 = "Update UserResponses Set Satisfaction = '" & strAnswer1 & "' Where Question_ID=" & CInt(Q_ID) & " and QuestionNo=" & CInt(q_no)
                Response.Write("Update query:" & query5 & "<br>")
                Using conn As New Data.OleDb.OleDbConnection(dbcon)
                    Using cmd As New Data.OleDb.OleDbCommand(query5, conn)
                        conn.Open()
                        Try
                            cmd.ExecuteNonQuery()
                        Catch ex As Exception
                            Literal1.Text = ex.Message
                        End Try
                        conn.Close()
                    End Using
                End Using
            Next

        End If
        If q_type = "Reason" And recordedR = True Then
            Dim ind_q, q_id, chosen As String
            Dim k As Integer
            Dim Query, q_no As String
            Dim value As String
            q_no = 0
            Dim radioList As RadioButtonList = DirectCast(Page.FindControl("RadioButtonList1"), RadioButtonList)
            Using conn2 As New Data.OleDb.OleDbConnection(dbcon)

                query4 = "SELECT UserResponses.Question_ID, UserResponses.RadioChosen, SatisfactionQs.Individual_Q FROM UserResponses INNER JOIN SatisfactionQs ON UserResponses.Question_ID = SatisfactionQs.Question_ID where SatisfactionQs.ChoiceType='Reason' and UserResponses.QuestionNo=" & CInt(currentQ)
                Response.Write(query4)
                conn2.Open()
                Using cmd As New OleDbCommand(query4, conn2)


                    Using sdr4 As OleDbDataReader = cmd.ExecuteReader()
                        k = 0
                        While sdr4.Read()
                            ind_q = sdr4("Individual_Q").ToString
                            q_id = sdr4("Question_ID").ToString
                            chosen = sdr4("RadioChosen").ToString
                            radioList.Items.Add(New ListItem(ind_q, q_id))
                            If chosen = 1 Then
                                radioList.Items(k).Selected = True
                            ElseIf chosen = 0 Then
                                radioList.Items(k).Selected = False
                            End If
                            k = k + 1
                        End While

                    End Using
                End Using
                RadioButtonList1.Visible = True
                RadioButtonList2.Visible = False
                conn2.Close()
            End Using
            Response.Write("Jesus is Lord")
            Response.Write(q_type)

            For i As Integer = 0 To RadioButtonList1.Items.Count - 1
                If RadioButtonList1.Items(i).Selected Then
                    'get the text value of the selected radio button
                    value = "1"
                Else
                    value = "0"
                End If
                Using conn1 As New Data.OleDb.OleDbConnection(dbcon)
                    query1 = "Select * From SatisfactionQs where Question_ID=" & CInt(RadioButtonList1.Items(i).Value)
                    conn1.Open()
                    Using cmd1 As New OleDbCommand(query1, conn1)
                        Using sdr As OleDbDataReader = cmd1.ExecuteReader()
                            While sdr.Read()
                                q_no = sdr("QuestionNo").ToString
                            End While
                        End Using
                    End Using
                    conn1.Close()
                End Using



                Query = "UPDATE UserResponses SET Radiochosen='" & value & "' Where Question_ID=" & CInt(RadioButtonList1.Items(i).Value) & " and QuestionNo=" & CInt(q_no)
                Response.Write(Query)
                Using conn1 As New Data.OleDb.OleDbConnection(dbcon)
                    Using cmd As New Data.OleDb.OleDbCommand(Query, conn1)
                        conn1.Open()
                        Try
                            cmd.ExecuteNonQuery()
                        Catch ex As Exception
                            Literal1.Text = ex.Message
                        End Try
                        conn1.Close()
                    End Using
                End Using
            Next
        End If
    End If

End Sub

Protected Sub btn_NextClick(sender As Object, e As EventArgs)
    Response.Redirect("TakeSurvey.aspx?sid=" + sid + "¤tQ=" + currentQ + "&status1=next")
End Sub

Protected Sub btn_PrevClick(sender As Object, e As EventArgs)
    Response.Write(q_type)
    Response.Write(currentQ)
    Response.Write(sid)
    Response.Redirect("TakeSurvey.aspx?sid=" + sid + "¤tQ=" + currentQ + "&status1=previous")
End Sub

End Class

<%@ Page Title="TakeSurvey" Language="VB" AutoEventWireup="true" CodeFile="TakeSurvey.aspx.vb" Inherits="_TakeSurvey" %>

<html>
<head></head>
   <body>
    <h2>
        Welcome to our Survey
    </h2>

        <form id="form2" runat="server">

<div>
    Service Request Description: <asp:Literal ID="descrp" runat="server" ></asp:Literal><br />
    Date Incident Reported: <asp:Label ID="dt_incident" runat="server" ></asp:Label><br />
    Department of Requestor: <asp:Label ID="r_dep" runat="server" ></asp:Label><br />
    Section of Requestor: <asp:Label ID="r_sect" runat="server" ></asp:Label><br /> 
    Requestor Name: <asp:Label ID="r_name" runat="server" ></asp:Label><br />
    IT Staff Assigned: <asp:Label ID="IT_staff" runat="server" ></asp:Label><br /><br />
    <asp:Literal ID="Literal1" runat="server" ></asp:Literal><br />

     <asp:GridView ID="GridQuiz" runat="server" AutoGenerateColumns="False" 

        ShowHeader="True" Width="700" EmptyDataRowStyle-CssClass="canon2" DataKeyNames="Question_ID" CellPadding="4" GridLines="None" CssClass="canon2">

    <RowStyle BackColor="#B3D7EF" ></RowStyle>

<EmptyDataRowStyle CssClass="canon2"></EmptyDataRowStyle>

    <Columns>



    <asp:TemplateField ItemStyle-VerticalAlign="Top" HeaderText="No." HeaderStyle-BorderWidth="0" HeaderStyle-BorderStyle="None" ItemStyle-BorderStyle="None" ItemStyle-BorderWidth="0" ItemStyle-CssClass="canon2">

    <ItemTemplate><%# Container.DataItemIndex + 1 %>

    </ItemTemplate>

</asp:TemplateField>

       <asp:TemplateField ItemStyle-VerticalAlign="Top" Visible="False" HeaderStyle-BorderWidth="0" HeaderStyle-BorderStyle="None" ItemStyle-BorderStyle="None" ItemStyle-BorderWidth="0" ItemStyle-CssClass="canon2">

    <ItemTemplate><%#Eval("Question_ID")%>

    </ItemTemplate>

</asp:TemplateField>

    <asp:TemplateField HeaderStyle-BorderWidth="0" HeaderText="Individual Question" HeaderStyle-BorderStyle="None" ItemStyle-BorderStyle="None" ItemStyle-BorderWidth="0" ItemStyle-VerticalAlign="Top" ItemStyle-CssClass="canon2" >

    <ItemTemplate>

   <%#Eval("Individual_Q")%>    
    </ItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderStyle-BorderWidth="0" HeaderText="Very Satisfied" HeaderStyle-BorderStyle="None" ItemStyle-BorderStyle="None" ItemStyle-BorderWidth="0" ItemStyle-VerticalAlign="Top" ItemStyle-CssClass="canon2" >
    <ItemTemplate>
        <asp:RadioButton ID="RadioOption1" runat="server" ValidationGroup="s" CssClass="canon2" ></asp:RadioButton>
  </ItemTemplate>
    </asp:TemplateField>
        <asp:TemplateField HeaderStyle-BorderWidth="0" HeaderText="Satisfied" HeaderStyle-BorderStyle="None" ItemStyle-BorderStyle="None" ItemStyle-BorderWidth="0" ItemStyle-VerticalAlign="Top" ItemStyle-CssClass="canon2" >
    <ItemTemplate>
        <asp:RadioButton ID="RadioOption2" runat="server" ValidationGroup="s" CssClass="canon2"  ></asp:RadioButton>
   </ItemTemplate>
    </asp:TemplateField>
        <asp:TemplateField HeaderStyle-BorderWidth="0" HeaderText="Dissatisfied" HeaderStyle-BorderStyle="None" ItemStyle-BorderStyle="None" ItemStyle-BorderWidth="0" ItemStyle-VerticalAlign="Top" ItemStyle-CssClass="canon2" >
    <ItemTemplate>
        <asp:RadioButton ID="RadioOption3" runat="server" ValidationGroup="s" CssClass="canon2"  ></asp:RadioButton>
   </ItemTemplate>
    </asp:TemplateField>
        <asp:TemplateField HeaderStyle-BorderWidth="0" HeaderText="Very Dissatisfied" HeaderStyle-BorderStyle="None" ItemStyle-BorderStyle="None" ItemStyle-BorderWidth="0" ItemStyle-VerticalAlign="Top" ItemStyle-CssClass="canon2" >
    <ItemTemplate>
        <asp:RadioButton ID="RadioOption4" runat="server" ValidationGroup="s" CssClass="canon2" ></asp:RadioButton>
    </ItemTemplate>
    </asp:TemplateField>
    </Columns>
    </asp:GridView>

    <asp:GridView ID="GridQuiz1" runat="server" AutoGenerateColumns="False" 

        ShowHeader="False" Width="422" 

        EmptyDataRowStyle-CssClass="canon2" DataKeyNames="Question_ID" CellPadding="4" 

        GridLines="None" CssClass="canon2">

    <RowStyle BackColor="#B3D7EF" ></RowStyle>

<EmptyDataRowStyle CssClass="canon2"></EmptyDataRowStyle>

    <Columns>



    <asp:TemplateField ItemStyle-VerticalAlign="Top" HeaderStyle-BorderWidth="0" HeaderStyle-BorderStyle="None" ItemStyle-BorderStyle="None" ItemStyle-BorderWidth="0" ItemStyle-CssClass="canon2">

    <ItemTemplate><%# Container.DataItemIndex + 1 %>

    </ItemTemplate>

</asp:TemplateField>

       <asp:TemplateField ItemStyle-VerticalAlign="Top" HeaderStyle-BorderWidth="0" HeaderStyle-BorderStyle="None" ItemStyle-BorderStyle="None" ItemStyle-BorderWidth="0" ItemStyle-CssClass="canon2">

    <ItemTemplate><%#Eval("Question_ID")%>

    </ItemTemplate>

</asp:TemplateField>

    <asp:TemplateField HeaderStyle-BorderWidth="0" HeaderStyle-BorderStyle="None" ItemStyle-BorderStyle="None" ItemStyle-BorderWidth="0" ItemStyle-VerticalAlign="Top" ItemStyle-CssClass="canon2" >

    <ItemTemplate>

   <%#Eval("Individual_Q")%>    
    </ItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderStyle-BorderWidth="0" HeaderText="Very Satisfied" HeaderStyle-BorderStyle="None" ItemStyle-BorderStyle="None" ItemStyle-BorderWidth="0" ItemStyle-VerticalAlign="Top" ItemStyle-CssClass="canon2" >
    <ItemTemplate>
        <asp:RadioButton ID="RadioOption1" Value="4"  runat="server" ValidationGroup="s" CssClass="canon2" ></asp:RadioButton>
  </ItemTemplate>
    </asp:TemplateField>
        <asp:TemplateField HeaderStyle-BorderWidth="0" HeaderText="Satisfied" HeaderStyle-BorderStyle="None" ItemStyle-BorderStyle="None" ItemStyle-BorderWidth="0" ItemStyle-VerticalAlign="Top" ItemStyle-CssClass="canon2" >
    <ItemTemplate>
        <asp:RadioButton ID="RadioOption2" Value="3"  runat="server" ValidationGroup="s" CssClass="canon2"  ></asp:RadioButton>
   </ItemTemplate>
    </asp:TemplateField>
        <asp:TemplateField HeaderStyle-BorderWidth="0" HeaderText="Dissatisfied" HeaderStyle-BorderStyle="None" ItemStyle-BorderStyle="None" ItemStyle-BorderWidth="0" ItemStyle-VerticalAlign="Top" ItemStyle-CssClass="canon2" >
    <ItemTemplate>
        <asp:RadioButton ID="RadioOption3" Value="2"  runat="server" ValidationGroup="s" CssClass="canon2"  ></asp:RadioButton>
   </ItemTemplate>
    </asp:TemplateField>
        <asp:TemplateField HeaderStyle-BorderWidth="0" HeaderText="Very Dissatisfied" HeaderStyle-BorderStyle="None" ItemStyle-BorderStyle="None" ItemStyle-BorderWidth="0" ItemStyle-VerticalAlign="Top" ItemStyle-CssClass="canon2" >
    <ItemTemplate>
        <asp:RadioButton ID="RadioOption4" Value="1"  runat="server" ValidationGroup="s" CssClass="canon2" ></asp:RadioButton>
    </ItemTemplate>
    </asp:TemplateField>
    </Columns>
    </asp:GridView>

<asp:Label ID="Label1" runat="server" Text=""></asp:Label>

    <asp:RadioButtonList ID="RadioButtonList2" Visible="false" runat="server" ></asp:RadioButtonList>

    <asp:RadioButtonList ID="RadioButtonList1" Visible="false" runat="server" ></asp:RadioButtonList>

    <asp:Button ID="btn_Prev" runat="server"  Text="PREVIOUS" OnClick="btn_PrevClick" ></asp:Button>
    <asp:Button ID="btn_Next" runat="server"  Text="NEXT" OnClick="btn_NextClick" ></asp:Button>
    <asp:Button ID="Complete" runat="server" Enabled="false" Visible="false" Text="Complete" ></asp:Button>
    <br />
    <br />
    <br />
</div>
</form>
   </body>
</html>

Hi,

Can somebody help me solve this? I can't update the answers of the survey into the database?

Why not use try-catch to trap and visualize errors, at least during test sessions? Once you can see the error message, the fix, almost always, will be more affordable. BTW, there is little difficulty to modify the query string by the user. See here and here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.