2013-03-06 70 views
0

我有一個DotNetNuke的皮膚與此代碼狀態:保存檢查的動態創建的單選按鈕

<%@ Control language="vb" AutoEventWireup="false" Explicit="True" Inherits="DotNetNuke.UI.Skins.Skin" %> 
<%@ Register TagPrefix="dnn" TagName="USER" Src="~/Admin/Skins/User.ascx" %> 

<div style="float:left; width:420px; height:335px;" id="divPerguntas" runat="server"></div> 
<asp:ImageButton ImageUrl="/Portals/_default/Skins/AdWin/img/Enviar.png" id="imgEnviar" runat="server" style="cursor:pointer;" /> 
<script runat="server"> 
Protected Sub EnviarClick() Handles imgEnviar.Click 

    Dim conexao As SqlConnection 
    Dim comando As SqlCommand 
    Dim myReader As SqlDataReader 
    Dim sql As String 

    sql = "SELECT S.SurveyID, SO.SurveyOptionID FROM AdWin_Demo.dbo.Surveys S INNER JOIN AdWin_Demo.dbo.SurveyOptions SO ON S.SurveyID = SO.SurveyID WHERE S.VideoId = " + Request.QueryString("id") + " ORDER BY S.ViewOrder, SO.ViewOrder" 
    conexao = New SqlConnection(connectionstring) 
    conexao.Open() 
    comando = New SqlCommand(sql, conexao) 

    myReader = comando.ExecuteReader 

    If myReader.HasRows Then 
     Dim dt As New DataTable 
     dt.Load(myReader) 

      Dim dnnUserCtrl As New DotNetNuke.Entities.Users.UserController 
      For Each dr As DataRow In dt.Rows 
       Dim radiobuttonToCheck As RadioButton = FindControl(dr("SurveyOptionID").ToString()) 
      If radiobuttonToCheck.Checked = True Then 
       sql = "INSERT INTO AdWin_Demo.dbo.Adwin_RespostasDadas (IDUser, SurveyOptionID) SELECT " & dnnUserCtrl.GetCurrentUserInfo.UserID & ", " & dr("SurveyOptionID").ToString() 
       comando = New SqlCommand(sql, conexao) 
       myReader = comando.ExecuteReader 

      End If 
      Next 

    End If 

    myReader.Close() 
    conexao.Close() 


End Sub 
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Init 

    Dim conexao As SqlConnection 
    Dim comando As SqlCommand 
    Dim myReader As SqlDataReader 
    Dim sql As String 

    sql = "SELECT S.SurveyID, S.Question, SO.OptionName, SO.SurveyOptionID FROM AdWin_Demo.dbo.Surveys S INNER JOIN AdWin_Demo.dbo.SurveyOptions SO ON S.SurveyID = SO.SurveyID WHERE S.VideoId = " + Request.QueryString("id") + " ORDER BY S.ViewOrder, S.SurveyID, SO.ViewOrder" 
    conexao = New SqlConnection(connectionstring) 
    conexao.Open() 
    comando = New SqlCommand(sql, conexao) 

    myReader = comando.ExecuteReader 


    If myReader.HasRows Then 
     Dim dt As New DataTable 
     dt.Load(myReader) 

     For Each dr As DataRow In dt.Rows 

      Dim rb As New RadioButton 
      rb.GroupName = "Group" & dr("SurveyID").ToString() 
      rb.ID = dr("SurveyOptionID").ToString() 
      rb.Text = dr("OptionName").ToString() 
      divPerguntas.Controls.Add(rb) 
      divPerguntas.Controls.Add(New LiteralControl("<br/>")) 

     Next 
     Dim hr As New HtmlGenericControl("hr") 
     divPerguntas.Controls.Add(hr) 
    End If 

    myReader.Close() 
    conexao.Close() 

End Sub 
</script> 

當我點擊圖像按鈕,我要發送到數據庫的用戶的答案,但單選按鈕disapear,我失去了檢查狀態...我應該如何解決?

回答