This is a migrated thread and some comments may be shown as answers.

Autocomplete not working with bootstrap

0 Answers 448 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Kristopher
Top achievements
Rank 1
Kristopher asked on 14 Mar 2017, 07:03 PM

I have an autocomplete on my page that is bound to a sqldatasource.  Not sure why it is not working the progress meter just spins and spins.  The reason i think its with bootstrap is because if i take the control and the sqldatasource to a blank page, it works?  I dont get an error so its hard to diagnose.  Please take a look at my code and tell me where the conflict is.  Thank You

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
 
 
<style>
         .numberCircle {
   border-radius: 50%;      
 
   width: 36px;
   height: 36px;
   line-height: 36px;
   vertical-align:middle;
   margin: 5px;
   background: #fff;
   border: 2px solid #666;
   color: #666;
   position: absolute;
    left: -50px;
   text-align: center;
   font: 28px Arial, sans-serif;
}
        .required {
            color: #e31937;
            font-family: Verdana;
            margin: 0 5px;
        }
 
        .field-validation-error {
            color: #e31937;
            font-weight: bold;
        }
</style>
 
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
 <asp:Literal ID="distID" runat="server" Text=""></asp:Literal>
    <asp:Literal ID="error" runat="server" Text=""></asp:Literal>
    <h4>Use this option to add a single student.  This is an ideal option prior to printing scan sheets and when only a few students need to be addedd.  If you
        already printed and distributed the scan sheets you need to print out a blank scan sheet and add the student responses directly into Remark. Please click here for more information on how to that. </h4>
    <br />
            <div class="container">
    <div class="btn-group btn-toggle">
        <asp:Button ID="btnElementary" CssClass="btn btn-primary" runat="server" Text="Elementary" OnClick="btnElementary_Click" ViewStateMode="Enabled" CausesValidation="False" />
        <asp:Button ID="btnSecondary" CssClass="btn btn-default" runat="server" Text="Secondary" OnClick="btnElementary_Click" ViewStateMode="Enabled" CausesValidation="False" />
    </div>
 
                  <br />
    <br />
</div>
  <div class="col-lg-6">
        <div class="numberCircle">1</div>
    </div
<div class="container">
        <div class="jumbotron">          
        <div class="row">
         <div class="form-group-lg">           
<div class="col-lg-2">     
<div class="form-group">
  <label class="col-2 col-form-label">Student ID</label>
  <div class="col-10">
    <input class="form-control" runat="server" type="text" value="" id="StudentID">
     <div class="collapse">
          <asp:RequiredFieldValidator ID="STUvalid" ValidationGroup="validSTU" runat="server" ErrorMessage="Student ID Required" Display="None" ControlToValidate="StudentID">
          </asp:RequiredFieldValidator>
          <asp:RequiredFieldValidator ID="STUValidSecondary" ValidationGroup="validSecondary" runat="server" ErrorMessage="Student ID Required" Display="None" ControlToValidate="StudentID">
          </asp:RequiredFieldValidator>
          </div>
  </div>
</div>
<div class="form-group">
  <label for="example-search-input" class="col-2 col-form-label">Student Name</label>
  <div class="col-10">
    <input class="form-control" runat="server" type="text" value="" id="Name">
    <div class="collapse">
          <asp:RequiredFieldValidator ID="stuNameValid" ValidationGroup="validSTU" runat="server" ErrorMessage="Student Name Required" Display="None" ControlToValidate="Name">
          </asp:RequiredFieldValidator>
          <asp:RequiredFieldValidator ID="stuNameValidSecondary" ValidationGroup="validSecondary" runat="server" ErrorMessage="Student Name Required" Display="None" ControlToValidate="Name">
          </asp:RequiredFieldValidator>
     </div>
  </div>
</div>
<div class="form-group">
  <label for="example-email-input" class="col-2 col-form-label">School ID</label>
  <div class="col-10">
      <asp:TextBox ID="tbSchoolID" runat="server" CssClass="form-control input-lg" TextMode="Number"></asp:TextBox
       <div class="collapse">
          <asp:RequiredFieldValidator ID="SchoValid" ValidationGroup="validSTU" runat="server" ErrorMessage="School ID Required" Display="None" ControlToValidate="tbSchoolID">
          </asp:RequiredFieldValidator>
          <asp:RequiredFieldValidator ID="SchoValidSecondary" ValidationGroup="validSecondary" runat="server" ErrorMessage="School ID Required" Display="None" ControlToValidate="tbSchoolID">
          </asp:RequiredFieldValidator>
     </div>
  </div>
</div>
<div class="form-group">
  <label for="example-url-input" class="col-2 col-form-label">Grade</label>
  <div class="col-10">
      <asp:DropDownList ID="ddlGrade"  CssClass="btn btn-default dropdown-toggle btn-lg" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlGrade_SelectedIndexChanged">
            <asp:ListItem class="dropdown-header">
                Grade
            </asp:ListItem>
          <asp:ListItem Text="K" Value="0"/>
          <asp:ListItem>1</asp:ListItem>
          <asp:ListItem>2</asp:ListItem>
          <asp:ListItem>3</asp:ListItem>
          <asp:ListItem>4</asp:ListItem>
          <asp:ListItem>5</asp:ListItem>
          <asp:ListItem>6</asp:ListItem>
          <asp:ListItem>7</asp:ListItem>
          <asp:ListItem>8</asp:ListItem>
          <asp:ListItem>9</asp:ListItem>
          <asp:ListItem>10</asp:ListItem>
          <asp:ListItem>11</asp:ListItem>
          <asp:ListItem>12</asp:ListItem>
      </asp:DropDownList>
  </div>
</div>
</div>
<div class="col-lg-2">
 
    </div>
 
 
<div class="col-lg-2">
 
<div class="form-group">
  <label for="example-tel-input" class="col-2 col-form-label">Ethnicity</label>
  <div class="col-10">
     <div class="col-10">
      <asp:DropDownList ID="ddlRace"  CssClass="btn btn-default dropdown-toggle btn-lg" runat="server">
          <asp:ListItem Enabled="False">-- Select Ethnicity --</asp:ListItem>
          <asp:ListItem Text="White" Value="WHT"/>
          <asp:ListItem Text="African American" Value="AA"/>
          <asp:ListItem Text="Hispanic" Value="HIS"/>
          <asp:ListItem Text="Asian" Value="Asian"/>
          <asp:ListItem Text="Other" Value="Other"/>
      </asp:DropDownList>
  </div>
  </div>
</div>
<div class="form-group">
  <label for="example-password-input" class="col-2 col-form-label">Language Fluency</label>
  <div class="col-10">
      <asp:DropDownList ID="ddlLF"  CssClass="btn btn-default dropdown-toggle btn-lg" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlLF_SelectedIndexChanged">
            <asp:ListItem class="dropdown-header">
                LF
            </asp:ListItem>
          <asp:ListItem Text="English Only" Value="EO"/>
          <asp:ListItem Text="English Learner" Value="EL"/>
          <asp:ListItem Text="IFEP" Value="IFEP"/>
          <asp:ListItem Text="RFEP" Value="RFEP"/>
      </asp:DropDownList>
  </div>
</div>
<div class="form-group"  id="LFlevel" runat="server">
  <label for="example-password-input" class="col-2 col-form-label">CELDT Level</label>
   <div class="col-10">
      <asp:DropDownList ID="ddlLF_level"  CssClass="btn btn-default dropdown-toggle btn-lg" runat="server">
           <asp:ListItem class="dropdown-header">
                Level
            </asp:ListItem>
          <asp:ListItem Text="Begining" Value="1"/>
          <asp:ListItem Text="Early Intermediate" Value="2"/>
          <asp:ListItem Text="Intermediate" Value="3"/>
          <asp:ListItem Text="Early Advanced" Value="4"/>
          <asp:ListItem Text="Advanced" Value="5"/>
      </asp:DropDownList>
  </div>
</div>
<div class="form-group">
  <label for="example-number-input" class="col-2 col-form-label">Special Education</label>
  <div class="col-10">
      <asp:DropDownList ID="ddlSped"  CssClass="btn btn-default dropdown-toggle btn-lg" runat="server">
           <asp:ListItem class="dropdown-header">
                SPED
            </asp:ListItem>
          <asp:ListItem Text="Yes" Value="Y"/>
          <asp:ListItem Text="No" Value=""/>
      </asp:DropDownList>
  </div>
</div>
<div class="form-group">
  <label for="example-datetime-local-input" class="col-2 col-form-label">US Entry Date</label>
  <div class="col-10">
      <telerik:RadDatePicker Skin="Bootstrap" ID="RDusDate" runat="server"></telerik:RadDatePicker>
 
  </div>
</div>
</div>
 
<div class="col-lg-2">
 
</div>
     
<div class="col-lg-2" id="DIVelemTeacher" runat="server">
    <div class="form-group">
  <label for="example-email-input" class="col-2 col-form-label">Elemtary Teacher</label>
  <div class="col-10">
      <telerik:RadAutoCompleteBox ID="ELEMautoTeacher" runat="server" Skin="Bootstrap" InputType="Text" DataSourceID="sqlTeacher" DataTextField="teacher" DataValueField="teacher" Filter="StartsWith" EmptyMessage="Start typing"></telerik:RadAutoCompleteBox>
      
  </div>
</div>
    </div>
        <%--  ---VALIDATION------%>
    <div class="col-lg-2" >
         <div class="form-group">
            <asp:ValidationSummary ID="ValidationSummary1" ValidationGroup="validSTU" CssClass="field-validation-error" DisplayMode="BulletList"   runat="server" />
         <asp:ValidationSummary ID="ValidationSummary2" ValidationGroup="validSecondary" CssClass="field-validation-error" DisplayMode="BulletList"   runat="server" />
         </div>       
    </div>
        <%------ END ------%>
        </div>
       </div>     
            <br />
            <br />
            <asp:Button ID="btnStudent" ValidationGroup="validSTU" CssClass="btn btn-primary" runat="server" Text="Add Student" OnClick="btnStudent_Click" />       
   </div
   </div>
     <div id="target" runat="server" class="hidden">
           <div class="col-lg-6">
        <div class="numberCircle">2</div>
    </div>
        <%-- ---BEGIN SECONDARY PERIODS-----%>
 
     <div class="container">
        <div class="jumbotron">      
                    <div class="form-inline">
                              <asp:DropDownList ID="ddlPeriod" runat="server" CssClass="btn btn-default dropdown-toggle btn-lg">
                           <asp:ListItem class="dropdown-header">
                                Period
                            </asp:ListItem>
                                <asp:ListItem>1</asp:ListItem>
                                <asp:ListItem>2</asp:ListItem>
                                <asp:ListItem>3</asp:ListItem>
                                <asp:ListItem>4</asp:ListItem>
                                <asp:ListItem>5</asp:ListItem>
                                <asp:ListItem>6</asp:ListItem>
                                <asp:ListItem>7</asp:ListItem>
                              </asp:DropDownList>                        
                        <asp:TextBox ID="tbTeacherName1" runat="server" Width="175px"  CssClass="form-control input-lg" placeholder="Teacher Name" ></asp:TextBox>
                            <div class="collapse">
                              <asp:RequiredFieldValidator ID="p1Teacher" ValidationGroup="validSecondary" runat="server" ErrorMessage="Period Teacher Name Required" Display="None" ControlToValidate="tbTeacherName1">
                              </asp:RequiredFieldValidator>
                            </div>
                        <asp:TextBox ID="tbTeacherID1" runat="server" CssClass="form-control input-lg" Width="115px" placeholder="TeacherID"></asp:TextBox>
                            <div class="collapse">
                              <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ValidationGroup="validSecondary" runat="server" ErrorMessage="Period Teacher ID Required" Display="None" ControlToValidate="tbTeacherID1">
                              </asp:RequiredFieldValidator>
                            </div>            
                        <asp:TextBox ID="tbCourse1" runat="server" CssClass="form-control input-lg" Width="175px" placeholder="Course Name"></asp:TextBox>
                            <div class="collapse">
                              <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ValidationGroup="validSecondary" runat="server" ErrorMessage="Course Name Required" Display="None" ControlToValidate="tbCourse1">
                              </asp:RequiredFieldValidator>
                            </div>
                        <asp:TextBox ID="tbCourseID1" runat="server" CssClass="form-control input-lg" Width="115px" placeholder="Course ID"></asp:TextBox>
                            <div class="collapse">
                              <asp:RequiredFieldValidator ID="RequiredFieldValidator3" ValidationGroup="validSecondary" runat="server" ErrorMessage="Course ID Required" Display="None" ControlToValidate="tbCourseID1">
                              </asp:RequiredFieldValidator>
                            </div>                   
                        <asp:DropDownList ID="ddlDept1" runat="server" CssClass="dropdown-toggle btn-lg" height="45px">
                           <asp:ListItem class="dropdown-header">
                                Dept
                            </asp:ListItem>
                                <asp:ListItem>ELA</asp:ListItem>
                                <asp:ListItem>Math</asp:ListItem>
                                <asp:ListItem>Hist</asp:ListItem>
                                <asp:ListItem>SCI</asp:ListItem>
                              </asp:DropDownList>
 
                        <asp:Button ID="btnPeriod1" ValidationGroup="validSecondary" runat="server" CssClass="btn btn-primary pull-right" Text="Insert this class" OnClick="btnPeriod1_Click" />
                        <br />
                      
       <div id="radio-group1" class="btn-group" data-toggle="collapse" data-target="#period2" aria-expanded="false" aria-controls="collapseExample">
                <h4>  <span class="glyphicon glyphicon-plus-sign" ></span> Add Another Class  </h4>
                    <br />                                     
        </div>
                    </div>
              <%--NEW PERIOD--%>
 
            <div class="collapse" id="period2">
                    <div class="form-inline">
                              <asp:DropDownList ID="ddlPeriod2" runat="server" CssClass="btn btn-default dropdown-toggle btn-lg">
                           <asp:ListItem class="dropdown-header">
                                Period
                            </asp:ListItem>
                                <asp:ListItem>1</asp:ListItem>
                                <asp:ListItem>2</asp:ListItem>
                                <asp:ListItem>3</asp:ListItem>
                                <asp:ListItem>4</asp:ListItem>
                                <asp:ListItem>5</asp:ListItem>
                                <asp:ListItem>6</asp:ListItem>
                                <asp:ListItem>7</asp:ListItem>
                              </asp:DropDownList>                        
                        <asp:TextBox ID="tbTeacherName2" runat="server" Width="175px"  CssClass="form-control input-lg" placeholder="Teacher Name"></asp:TextBox>
          
                        <asp:TextBox ID="tbTeacherID2" runat="server" CssClass="form-control input-lg" Width="115px" placeholder="TeacherID"></asp:TextBox>
              
                        <asp:TextBox ID="tbCourse2" runat="server" CssClass="form-control input-lg" Width="175px" placeholder="Course Name"></asp:TextBox>
 
                        <asp:TextBox ID="tbCourseID2" runat="server" CssClass="form-control input-lg" Width="115px" placeholder="Course ID"></asp:TextBox>
                     
                        <asp:DropDownList ID="ddlDept2" runat="server" CssClass="btn btn-default dropdown-toggle btn-lg">
                           <asp:ListItem class="dropdown-header">
                                Dept
                            </asp:ListItem>
                                <asp:ListItem>ELA</asp:ListItem>
                                <asp:ListItem>Math</asp:ListItem>
                                <asp:ListItem>Hist</asp:ListItem>
                                <asp:ListItem>SCI</asp:ListItem>
                              </asp:DropDownList>                       
                        <asp:Button ID="btnPeriod2" runat="server" ValidationGroup="validSecondary" CssClass="btn btn-primary pull-right" Text="Insert this class" OnClick="btnPeriod2_Click" Enabled="False" />
                           <div id="radio-group2" class="btn-group" data-toggle="collapse" data-target="#period3" aria-expanded="false" aria-controls="collapseExample">
                                    <h4>  <span class="glyphicon glyphicon-plus-sign" ></span> Add Another Class  </h4>
                                        <br />                                     
                            </div>
                    </div>
                </div>
 
         <%--  ----------- NEW PERIOD-----------%>
               <div class="collapse" id="period3">
                    <div class="form-inline">
                              <asp:DropDownList ID="ddlPeriod3" runat="server" CssClass="btn btn-default dropdown-toggle btn-lg">
                           <asp:ListItem class="dropdown-header">
                                Period
                            </asp:ListItem>
                                <asp:ListItem>1</asp:ListItem>
                                <asp:ListItem>2</asp:ListItem>
                                <asp:ListItem>3</asp:ListItem>
                                <asp:ListItem>4</asp:ListItem>
                                <asp:ListItem>5</asp:ListItem>
                                <asp:ListItem>6</asp:ListItem>
                                <asp:ListItem>7</asp:ListItem>
                              </asp:DropDownList>                        
                        <asp:TextBox ID="tbTeacherName3" runat="server" Width="175px"  CssClass="form-control input-lg" placeholder="Teacher Name" ></asp:TextBox>
          
                        <asp:TextBox ID="tbTeacherID3" runat="server" CssClass="form-control input-lg" Width="115px" placeholder="TeacherID"></asp:TextBox>
              
                        <asp:TextBox ID="tbCourse3" runat="server" CssClass="form-control input-lg" Width="175px" placeholder="Course Name"></asp:TextBox>
 
                        <asp:TextBox ID="tbCourseID3" runat="server" CssClass="form-control input-lg" Width="115px" placeholder="Course ID"></asp:TextBox>
                     
                        <asp:DropDownList ID="ddlDept3" runat="server" CssClass="btn btn-default dropdown-toggle btn-lg">
                           <asp:ListItem class="dropdown-header">
                                Dept
                            </asp:ListItem>
                                <asp:ListItem>ELA</asp:ListItem>
                                <asp:ListItem>Math</asp:ListItem>
                                <asp:ListItem>Hist</asp:ListItem>
                                <asp:ListItem>SCI</asp:ListItem>
                              </asp:DropDownList>
                         
                     <asp:Button ID="btnPeriod3" runat="server" CssClass="btn btn-primary pull-right" Text="Insert this class" OnClick="btnPeriod3_Click" />
                           <div id="radio-group3" class="btn-group" data-toggle="collapse" data-target="#period4" aria-expanded="false" aria-controls="collapseExample">
                                    <h4>  <span class="glyphicon glyphicon-plus-sign" ></span> Add Another Class  </h4>
                                        <br />                                     
                            </div>
                    </div>
                </div>
 
              <%--  ----------- NEW PERIOD-----------%>
               <div class="collapse" id="period4">
                    <div class="form-inline">
                              <asp:DropDownList ID="ddlPeriod4" runat="server" CssClass="btn btn-default dropdown-toggle btn-lg">
                           <asp:ListItem class="dropdown-header">
                                Period
                            </asp:ListItem>
                                <asp:ListItem>1</asp:ListItem>
                                <asp:ListItem>2</asp:ListItem>
                                <asp:ListItem>3</asp:ListItem>
                                <asp:ListItem>4</asp:ListItem>
                                <asp:ListItem>5</asp:ListItem>
                                <asp:ListItem>6</asp:ListItem>
                                <asp:ListItem>7</asp:ListItem>
                              </asp:DropDownList>                        
                        <asp:TextBox ID="tbTeacherName4" runat="server" Width="175px"  CssClass="form-control input-lg" placeholder="Teacher Name" ></asp:TextBox>
          
                        <asp:TextBox ID="tbTeacherID4" runat="server" CssClass="form-control input-lg" Width="115px" placeholder="TeacherID"></asp:TextBox>
              
                        <asp:TextBox ID="tbCourse4" runat="server" CssClass="form-control input-lg" Width="175px" placeholder="Course Name"></asp:TextBox>
 
                        <asp:TextBox ID="tbCourseID4" runat="server" CssClass="form-control input-lg" Width="115px" placeholder="Course ID"></asp:TextBox>
                     
                        <asp:DropDownList ID="ddlDept4" runat="server" CssClass="btn btn-default dropdown-toggle btn-lg">
                           <asp:ListItem class="dropdown-header">
                                Dept
                            </asp:ListItem>
                                <asp:ListItem>ELA</asp:ListItem>
                                <asp:ListItem>Math</asp:ListItem>
                                <asp:ListItem>Hist</asp:ListItem>
                                <asp:ListItem>SCI</asp:ListItem>
                              </asp:DropDownList>
                        <asp:Button ID="btnPeriod4" runat="server" CssClass="btn btn-primary pull-right" Text="Insert this class" OnClick="btnPeriod4_Click" />
                        <br />
                      
                    </div>
                </div>
 
         </div>
 
    </div
                  
    </div>
 
    <br />
    <br />
    <br />
 
   <script>
            $('.glyphicon').click(function () {
            $(this).toggleClass('glyphicon glyphicon-plus-sign').toggleClass('glyphicon glyphicon-minus-sign');
        });
    </script>
 
    
     
    <asp:SqlDataSource ID="sqlTeacher" runat="server" ConnectionString="<%$ ConnectionStrings:MyMatrixConnectionString %>" ProviderName="<%$ ConnectionStrings:MyMatrixConnectionString.ProviderName %>" SelectCommand="SELECT DISTINCT teacher FROM CRS">
        <SelectParameters>
            <asp:SessionParameter Name="DistrictID" SessionField="DistrictID" />
        </SelectParameters>
    </asp:SqlDataSource>
 
</asp:Content>

 

 

namespace Matrix_Builder
{
    public partial class addStudent : System.Web.UI.Page
    {
        MembershipUser username = Membership.GetUser();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                LFlevel.Visible = false;
                //period.Visible = false;
                //distID.Text = Session["DistrictID"].ToString();
            
        }
 
        protected void btnStudent_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                int dID = 0;
                var DistrictID = Session["DistrictID"];
                dID = Convert.ToInt32(DistrictID);
 
                //GET MEMBERSHIP USERNAME!
                string storeProc = "sp_InsertSTU";
                SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString);
                conn.Open();
                DateTime dt = Convert.ToDateTime(RDusDate.SelectedDate);
                string temp = dt.ToShortDateString();
 
                try
                {
                    SqlCommand cmd = new SqlCommand(storeProc, conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@DistrictID", dID));
                    cmd.Parameters.Add(new SqlParameter("@username", username.ToString()));
                    cmd.Parameters.Add(new SqlParameter("@schoolID", tbSchoolID.Text));
                    cmd.Parameters.Add(new SqlParameter("@PID", StudentID.Value));
                    cmd.Parameters.Add(new SqlParameter("@Student_Name", Name.Value));
                    cmd.Parameters.Add(new SqlParameter("@grade", ddlGrade.SelectedValue.ToString()));
                    cmd.Parameters.Add(new SqlParameter("@ethnicity", ddlRace.SelectedValue.ToString()));
                    cmd.Parameters.Add(new SqlParameter("@LF", ddlLF.SelectedValue.ToString()));
                    cmd.Parameters.Add(new SqlParameter("@CELDT_LVL", ddlLF_level.SelectedValue.ToString()));
                    cmd.Parameters.Add(new SqlParameter("@SPED", ddlSped.SelectedValue.ToString()));
                    cmd.Parameters.Add(new SqlParameter("@US_entry_date", temp));
                    cmd.ExecuteScalar();
                    conn.Close();
 
                    distID.Text = "Student Demographic Data Successfully Inserted";
                }
 
                catch (Exception ex)
 
                {
                    error.Text = ex.Message;
                }
            }
 
            if (btnElementary.CssClass == "btn btn-primary" & Page.IsValid)
            {
                string Tname = ELEMautoTeacher.Text;
                string teachID = "";
                string course = ELEMautoTeacher.Text;
                string courseID = ddlGrade.SelectedValue;
                string period = "E";
                string dept = ddlGrade.SelectedValue;
                string user = username.ToString();
                var DistrictID = Session["DistrictID"].ToString();
                var studentID = StudentID.Value;
                var schoolID = tbSchoolID.Text;
 
                Dictionary<string, string> testdir = new Dictionary<string, string>
                        {
                            {"@username",user },
                            {"@DistrictID",DistrictID },
                            {"@teacher",Tname },
                            {"@TeacherID", teachID },
                            {"@CO", course },
                            {"@CN", courseID },
                            {"@period", period },
                            {"@PID", studentID },
                            {"@schoolID", schoolID },
                            {"@dept", dept }
                        };
                string testconnectString = ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;
 
                SQLMethod("sp_InsertCRS", testconnectString, testdir, btnPeriod1);
            }
        }
 
        protected void ddlGrade_SelectedIndexChanged(object sender, EventArgs e)
        {
            int i = Int32.Parse(ddlGrade.SelectedValue);
            if (i > 6)
            {
                btnElementary.CssClass = "btn btn-default";
                btnSecondary.CssClass = "btn btn-primary";
                target.Attributes["class"] = "";
                DIVelemTeacher.Visible = false;
            }
            else
            {
                btnElementary.CssClass = "btn btn-primary";
                btnSecondary.CssClass = "btn btn-default";
                target.Attributes["class"] = "collapse";
                DIVelemTeacher.Visible = true;
            }
        }
 
        protected void ddlLF_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlLF.SelectedValue == "EL")
            {
                LFlevel.Visible = true;
            }
            else
            {
                LFlevel.Visible = false;
            }
             
        }
 
        protected void btnElementary_Click(object sender, EventArgs e)
        {
            if (sender == btnSecondary)
            {
                btnElementary.CssClass = "btn btn-default";
                btnSecondary.CssClass = "btn btn-primary";
                target.Attributes["class"] = "";
                DIVelemTeacher.Visible = false;
            }
 
            if (sender == btnElementary)
            {
                btnElementary.CssClass = "btn btn-primary";
                btnSecondary.CssClass = "btn btn-default";
                target.Attributes["class"] = "collapse";
                DIVelemTeacher.Visible = true;
            }
        }
 
        protected void btnSecondary_Click(object sender, EventArgs e)
        {          
                btnElementary.CssClass = "btn btn-primary";
                target.Attributes["class"] = "collapse";           
        }
 
        protected void btnPeriod1_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                 
                string Tname = tbTeacherName1.Text;
                string teachID = tbTeacherID1.Text;
                string course = tbCourse1.Text;
                string courseID = tbCourseID1.Text;
                string period = ddlPeriod.SelectedValue;
                string dept = ddlDept1.SelectedValue;
                string user = username.ToString();
                var DistrictID = Session["DistrictID"].ToString();
                var studentID = StudentID.Value;
                var schoolID = tbSchoolID.Text;
 
                Dictionary<string, string> testdir = new Dictionary<string, string>
                {
                    {"@username",user },
                    {"@DistrictID",DistrictID },
                    {"@teacher",Tname },
                    {"@TeacherID", teachID },
                    {"@CO", course },
                    {"@CN", courseID },
                    {"@period", period },
                    {"@PID", studentID },
                    {"@schoolID", schoolID },
                    {"@dept", dept }
                    
                };
                string testconnectString = ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;
 
                SQLMethod("sp_InsertCRS", testconnectString, testdir, btnPeriod1);
 
            }
        }
 
        protected void btnPeriod2_Click(object sender, EventArgs e)
        {
            string Tname = tbTeacherName2.Text;
            string teachID = tbTeacherID2.Text;
            string course = tbCourse2.Text;
            string courseID = tbCourseID2.Text;
            string period = ddlPeriod2.SelectedValue;
            string dept = ddlDept2.SelectedValue;
 
            string user = username.ToString();
            var DistrictID = Session["DistrictID"].ToString();
            var studentID = StudentID.Value;
            var schoolID = tbSchoolID.Text;
             
 
            Dictionary<string, string> testdir = new Dictionary<string, string>
                {
                    {"@username",user },
                    {"@DistrictID",DistrictID },
                    {"@teacher",Tname },
                    {"@TeacherID", teachID },
                    {"@CO", course },
                    {"@CN", courseID },
                    {"@period", period },
                    {"@PID", studentID },
                    {"@schoolID", schoolID },
                    {"@dept", dept }
 
                };
 
            string testconnectString = ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;
 
            SQLMethod("sp_InsertCRS", testconnectString, testdir, btnPeriod2);
        }
 
        public void SQLMethod(string storeProc, string connectString, Dictionary<string, string> dir, Button btn)
        {
 
            SqlConnection conn = new SqlConnection(connectString);
            conn.Open();
 
            try
            {
                SqlCommand cmd = new SqlCommand(storeProc, conn);
                cmd.CommandType = CommandType.StoredProcedure;
                foreach (KeyValuePair<string, string> keyValue in dir)
                {
                    cmd.Parameters.Add(new SqlParameter(keyValue.Key, keyValue.Value));
                }
 
                cmd.ExecuteScalar();
                conn.Close();
 
                btn.Text = "Success";
                btn.CssClass = "btn btn-info pull-right";
                btn.Enabled = false;
 
            }
            catch (Exception ex)
            {
                distID.Text = ex.Message;
            }
        }
 
        protected void btnPeriod3_Click(object sender, EventArgs e)
        {
            string Tname = tbTeacherName3.Text;
            string teachID = tbTeacherID3.Text;
            string course = tbCourse3.Text;
            string courseID = tbCourseID3.Text;
            string period = ddlPeriod3.SelectedValue;
            string dept = ddlDept3.SelectedValue;
 
            string user = username.ToString();
            var DistrictID = Session["DistrictID"].ToString();
            var studentID = StudentID.Value;
            var schoolID = tbSchoolID.Text;
 
 
            Dictionary<string, string> testdir = new Dictionary<string, string>
                {
                    {"@username",user },
                    {"@DistrictID",DistrictID },
                    {"@teacher",Tname },
                    {"@TeacherID", teachID },
                    {"@CO", course },
                    {"@CN", courseID },
                    {"@period", period },
                    {"@PID", studentID },
                    {"@schoolID", schoolID },
                    {"@dept", dept }
 
                };
 
            string testconnectString = ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;
 
            SQLMethod("sp_InsertCRS", testconnectString, testdir, btnPeriod3);
        }
 
        protected void btnPeriod4_Click(object sender, EventArgs e)
        {
            string Tname = tbTeacherName4.Text;
            string teachID = tbTeacherID4.Text;
            string course = tbCourse4.Text;
            string courseID = tbCourseID4.Text;
            string period = ddlPeriod4.SelectedValue;
            string dept = ddlDept4.SelectedValue;
 
            string user = username.ToString();
            var DistrictID = Session["DistrictID"].ToString();
            var studentID = StudentID.Value;
            var schoolID = tbSchoolID.Text;
 
 
            Dictionary<string, string> testdir = new Dictionary<string, string>
                {
                    {"@username",user },
                    {"@DistrictID",DistrictID },
                    {"@teacher",Tname },
                    {"@TeacherID", teachID },
                    {"@CO", course },
                    {"@CN", courseID },
                    {"@period", period },
                    {"@PID", studentID },
                    {"@schoolID", schoolID },
                    {"@dept", dept }
 
                };
 
            string testconnectString = ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;
 
            SQLMethod("sp_InsertCRS", testconnectString, testdir, btnPeriod4);
        }
 
 
    }

No answers yet. Maybe you can help?

Tags
AutoCompleteBox
Asked by
Kristopher
Top achievements
Rank 1
Share this question
or