无法修改取消装箱转换的结果ASP.Net

时间:2019-02-11 18:18:27

标签: c# asp.net

因此,基本上我需要获得 Table1 的行数。 我创建了一个将人存储在表1中的会话,但是当我为我的 int计数器创建一个 Session 时,出现了错误< / strong> “无法修改取消装箱转换的结果” 。而且,我想问一下,如何将行号添加到表1 中的“ issaugotasTekstas” (我的人)中? 征求您的意见!

        namespace ValidWeb
    {
        public partial class WebForm1 : System.Web.UI.Page
        {
            private String issaugotasTekstas;
            protected void Page_Load(object sender, EventArgs e)
            {
                if (DropDownList1.Items.Count == 0)
                {
                    DropDownList1.Items.Add("-");
                    for (int i = 14; i <= 25; i++)
                    {
                        DropDownList1.Items.Add(i.ToString());
                    }
                }
                issaugotasTekstas = (string)Session["Registruoti"]; // session for added people
                RegistruotasAsmuo(issaugotasTekstas);
                int sk = DalyviuSk(Table1);
                (int)Session["Dalyviu sk"] = sk; // ERROR HERE
            }


            protected void Button1_Click(object sender, EventArgs e)
            {
                string selected = "";

                foreach (ListItem item in CheckBoxList1.Items)
                {
                    if (item.Selected)
                    {
                        selected += item.ToString() + " | ";
                    }
                }
                issaugotasTekstas = /*row number */ TextBox1.Text + " | " + TextBox2.Text + " | " + TextBox3.Text + " | " + DropDownList1.SelectedValue + " | " + selected;
// how can i add row number for each row?
                RegistruotasAsmuo(issaugotasTekstas);
                Session["Registruoti"] = issaugotasTekstas;
            }


            private void RegistruotasAsmuo(string tekstas)
            {
                TableCell cell = new TableCell();
                cell.Text = tekstas;

                TableRow row = new TableRow();
                row.Cells.Add(cell);

                Table1.Rows.Add(row);
            }

            private int DalyviuSk(Table table)
            {
                return Table1.Rows.Count;
            }

            protected void Button2_Click(object sender, EventArgs e)
            {
                Table1.Rows.Clear();
            }
        }
    }

0 个答案:

没有答案