Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ipt根据您控件的Id。使用GoogleChrome并从源代码处使用F12调试Java脚本。 <asp:CheckBoxList ID="module_semester_1" runat="server" DataSourceID="semester_C#_Asp.net - Fatal编程技术网

C# ipt根据您控件的Id。使用GoogleChrome并从源代码处使用F12调试Java脚本。 <asp:CheckBoxList ID="module_semester_1" runat="server" DataSourceID="semester

C# ipt根据您控件的Id。使用GoogleChrome并从源代码处使用F12调试Java脚本。 <asp:CheckBoxList ID="module_semester_1" runat="server" DataSourceID="semester,c#,asp.net,C#,Asp.net,ipt根据您控件的Id。使用GoogleChrome并从源代码处使用F12调试Java脚本。 <asp:CheckBoxList ID="module_semester_1" runat="server" DataSourceID="semester1" DataTextField="module_name" DataValueField="module_id" ></asp:CheckBoxList> <asp:Button Command

ipt根据您控件的Id。使用GoogleChrome并从源代码处使用F12调试Java脚本。
<asp:CheckBoxList ID="module_semester_1" runat="server" DataSourceID="semester1" DataTextField="module_name" DataValueField="module_id" ></asp:CheckBoxList>
            <asp:Button CommandName="NextView" ID="btnnext2" runat="server" Text="Next" OnClick="btnnext2_Click" />
protected void btnnext2_Click(object sender, EventArgs e)
    {
        String user = username.Text;

        string ConnectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlConnection myConnection = new SqlConnection(ConnectionString);

        myConnection.Open();

        int count = module_semester_1.Items.Count;

        for (int i = 0; i < count; i++)
        {
            if (module_semester_1.Items[i].Selected)
            {
                string value = module_semester_1.Items[i].Value;

                String query = "INSERT INTO students_vs_modules (student_no, module_id) VALUES (@student_no, @module_id)";

                SqlCommand myCommand = new SqlCommand(query, myConnection);
                myCommand.Parameters.AddWithValue("@student_no", user);
                myCommand.Parameters.AddWithValue("@module_id", value);

                myCommand.ExecuteNonQuery();       
            }
        }      
        myConnection.Close();
    }
   <script type="text/javascript">
        var limit = 3;
        $(function () { 
        $('[id*="module_semester_1"]').on('change', function (evt) {
            if ($('[id*="module_semester_1"]:checked').length > limit) {
                this.checked = false;
                alert('cannot select more than ' + limit);
            }
        });
        });
    </script>
    <asp:CheckBoxList ID="module_semester_1" runat="server">
        <asp:ListItem Value="1">1</asp:ListItem>
        <asp:ListItem Value="2">2</asp:ListItem>
        <asp:ListItem Value="3">3</asp:ListItem>
        <asp:ListItem Value="4">4</asp:ListItem>
        <asp:ListItem Value="5">5</asp:ListItem>
    </asp:CheckBoxList>