protected void Button2_Click(object sender, EventArgs e)
        {
            int flag = 0;
            for (int j = 0; j < 10; j++)
            {

                for (int i = 0; i < 10; i++)
                {

                    //  i = j - 1;
                    Label lbl = new Label();
                    Label lb = new Label();
                    lbl.ID = "Label" + i;
                    lb.ID = "Label" + j;
                    if (lb.Text.Equals(lbl.Text)&& lb.Text != null)
                    {
                        Label21.Text = " Same Colleges Are selcted , Please Edit list";
                        Label21.Visible = true;
                        flag = 1;
                    }
                }
            }
            if(flag==1)
            {
                collegeSelected c = new collegeSelected();
                c.op1 = Label1.Text;
                c.op2 = Label2.Text;
                c.op3 = Label3.Text;
                c.op4 = Label4.Text;
                c.op5 = Label5.Text;
                c.op6 = Label6.Text;
                c.op7 = Label7.Text;
                c.op8 = Label8.Text;
                c.op9 = Label9.Text;
                c.op10 = Label10.Text;
                string json = JsonConvert.SerializeObject(c);
                string p = Session["login"].ToString();
                string s = ConfigurationManager.ConnectionStrings["connection"].ConnectionString;
                SqlConnection con = new SqlConnection(s);
                SqlCommand cmd = new SqlCommand("Update Student set selected = '"+json+"'  where rollno = '"+p+"' ", con);
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
                Response.Redirect("Show.aspx");
            }
        }
        protected void resultCalc(object sender, EventArgs e)
        {
            int count = name.Count;
            int coll = namecoll.Count;
            int flag = 0;
            c = 0;
            for (int i = 0; i < count; i++)
            {
                flag = 0;
                if (allot[i].ToString() != "lol")
                    flag = 1;
                    obj = JsonConvert.DeserializeObject<collegeSelected>(selected[i].ToString());
                    while (c < coll)
                    {
                        if (flag==1)
                        {
                            break;
                        }
                        if (obj.op1 == (namecoll[c].ToString()))
                        {

                        if (seatsleft[c].ToString() != "0")
                        {
                            int se = int.Parse(seatsleft[c].ToString());
                            se--;
                            seatsleft[c] = se.ToString();
                            allot[i] = obj.op1;
                        }

                            break;
                        }
                        else
                        {
                            c++;
                        }
                    }
            }
            c = 0;
            for (int i = 0; i < count; i++)
            {
                flag = 0;
                if (allot[i].ToString() != "lol")
                    flag = 1;
                obj = JsonConvert.DeserializeObject<collegeSelected>(selected[i].ToString());
                while (c < coll)
                {
                    if (flag == 1)
                    {
                        break;
                    }
                    if (obj.op2 == (namecoll[c].ToString()))
                    {

                        if (seatsleft[c].ToString() != "0")
                        {
                            int se = int.Parse(seatsleft[c].ToString());
                            se--;
                            seatsleft[c] = se.ToString();
                            allot[i] = obj.op1;
                        }

                        break;
                    }
                    else
                    {
                        c++;
                    }
                }
            }
            c = 0; for (int i = 0; i < count; i++)
            {
                flag = 0;
                if (allot[i].ToString() != "lol")
                    flag = 1;
                obj = JsonConvert.DeserializeObject<collegeSelected>(selected[i].ToString());
                while (c < coll)
                {
                    if (flag == 1)
                    {
                        break;
                    }
                    if (obj.op3 == (namecoll[c].ToString()))
                    {

                        if (seatsleft[c].ToString() != "0")
                        {
                            int se = int.Parse(seatsleft[c].ToString());
                            se--;
                            seatsleft[c] = se.ToString();
                            allot[i] = obj.op1;
                        }

                        break;
                    }
                    else
                    {
                        c++;
                    }
                }
            }
            c = 0; for (int i = 0; i < count; i++)
            {
                flag = 0;
                if (allot[i].ToString() != "lol")
                    flag = 1;
                obj = JsonConvert.DeserializeObject<collegeSelected>(selected[i].ToString());
                while (c < coll)
                {
                    if (flag == 1)
                    {
                        break;
                    }
                    if (obj.op4 == (namecoll[c].ToString()))
                    {

                        if (seatsleft[c].ToString() != "0")
                        {
                            int se = int.Parse(seatsleft[c].ToString());
                            se--;
                            seatsleft[c] = se.ToString();
                            allot[i] = obj.op1;
                        }

                        break;
                    }
                    else
                    {
                        c++;
                    }
                }
            }
            c = 0; for (int i = 0; i < count; i++)
            {
                flag = 0;
                if (allot[i].ToString() != "lol")
                    flag = 1;
                obj = JsonConvert.DeserializeObject<collegeSelected>(selected[i].ToString());
                while (c < coll)
                {
                    if (flag == 1)
                    {
                        break;
                    }
                    if (obj.op5 == (namecoll[c].ToString()))
                    {

                        if (seatsleft[c].ToString() != "0")
                        {
                            int se = int.Parse(seatsleft[c].ToString());
                            se--;
                            seatsleft[c] = se.ToString();
                            allot[i] = obj.op1;
                        }

                        break;
                    }
                    else
                    {
                        c++;
                    }
                }
            }
            c = 0; for (int i = 0; i < count; i++)
            {
                flag = 0;
                if (allot[i].ToString() != "lol")
                    flag = 1;
                obj = JsonConvert.DeserializeObject<collegeSelected>(selected[i].ToString());
                while (c < coll)
                {
                    if (flag == 1)
                    {
                        break;
                    }
                    if (obj.op6 == (namecoll[c].ToString()))
                    {

                        if (seatsleft[c].ToString() != "0")
                        {
                            int se = int.Parse(seatsleft[c].ToString());
                            se--;
                            seatsleft[c] = se.ToString();
                            allot[i] = obj.op1;
                        }

                        break;
                    }
                    else
                    {
                        c++;
                    }
                }
            }
            c = 0; for (int i = 0; i < count; i++)
            {
                flag = 0;
                if (allot[i].ToString() != "lol")
                    flag = 1;
                obj = JsonConvert.DeserializeObject<collegeSelected>(selected[i].ToString());
                while (c < coll)
                {
                    if (flag == 1)
                    {
                        break;
                    }
                    if (obj.op7 == (namecoll[c].ToString()))
                    {

                        if (seatsleft[c].ToString() != "0")
                        {
                            int se = int.Parse(seatsleft[c].ToString());
                            se--;
                            seatsleft[c] = se.ToString();
                            allot[i] = obj.op1;
                        }

                        break;
                    }
                    else
                    {
                        c++;
                    }
                }
            }
            c = 0; for (int i = 0; i < count; i++)
            {
                flag = 0;
                if (allot[i].ToString() != "lol")
                    flag = 1;
                obj = JsonConvert.DeserializeObject<collegeSelected>(selected[i].ToString());
                while (c < coll)
                {
                    if (flag == 1)
                    {
                        break;
                    }
                    if (obj.op8 == (namecoll[c].ToString()))
                    {

                        if (seatsleft[c].ToString() != "0")
                        {
                            int se = int.Parse(seatsleft[c].ToString());
                            se--;
                            seatsleft[c] = se.ToString();
                            allot[i] = obj.op1;
                        }

                        break;
                    }
                    else
                    {
                        c++;
                    }
                }
            }
            c = 0; for (int i = 0; i < count; i++)
            {
                flag = 0;
                if (allot[i].ToString() != "lol")
                    flag = 1;
                obj = JsonConvert.DeserializeObject<collegeSelected>(selected[i].ToString());
                while (c < coll)
                {
                    if (flag == 1)
                    {
                        break;
                    }
                    if (obj.op9 == (namecoll[c].ToString()))
                    {

                        if (seatsleft[c].ToString() != "0")
                        {
                            int se = int.Parse(seatsleft[c].ToString());
                            se--;
                            seatsleft[c] = se.ToString();
                            allot[i] = obj.op1;
                        }

                        break;
                    }
                    else
                    {
                        c++;
                    }
                }
            }
            c = 0; for (int i = 0; i < count; i++)
            {
                flag = 0;
                if (allot[i].ToString() != "lol")
                    flag = 1;
                obj = JsonConvert.DeserializeObject<collegeSelected>(selected[i].ToString());
                while (c < coll)
                {
                    if (flag == 1)
                    {
                        break;
                    }
                    if (obj.op10 == (namecoll[c].ToString()))
                    {

                        if (seatsleft[c].ToString() != "0")
                        {
                            int se = int.Parse(seatsleft[c].ToString());
                            se--;
                            seatsleft[c] = se.ToString();
                            allot[i] = obj.op1;
                        }

                        break;
                    }
                    else
                    {
                        c++;
                    }
                }
            }
            c = 0;

            string s = ConfigurationManager.ConnectionStrings["connection"].ConnectionString;
                SqlConnection con = new SqlConnection(s);

            for (int i = 0; i < count; i++)
            {
                SqlCommand cmd = new SqlCommand("update Student set allot=@allot where rank=@rank", con);
                con.Open();
                cmd.Parameters.AddWithValue("@allot", allot[i]);
                cmd.Parameters.AddWithValue("@rank", rank[i]);
                cmd.ExecuteNonQuery();
                con.Close();
            }

                for (int j = 0; j < coll; j++)
                {
                SqlCommand cmd1 = new SqlCommand("update College set seatsleft=@seatleft where name=@name", con);
                con.Open();
                cmd1.Parameters.AddWithValue("@seatleft", seatsleft[j]);
                cmd1.Parameters.AddWithValue("@name", namecoll[j]);
                cmd1.ExecuteNonQuery();
                con.Close();
                }
        }