I have a button when i click on button then 3textBoxes generated first time and then after it two textboxes generated.I want toget value oftbtextbox in 3rd textbox.I mean sum of textbox in 3rd textbox.But I'm gettingnullvalue oftextbox`.

 <asp:ScriptManager runat="server"></asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
             <asp:Button ID="Button1" runat="server" Text="Add New" OnClick="create" />
    <asp:Panel ID="Panel1" runat="server"></asp:Panel>
            </ContentTemplate>
        </asp:UpdatePanel>

ASPX.CS

  protected void Page_Load(object sender, EventArgs e)
    {

    }


     static int i = 0;
    TextBox tb;
    TextBox tb2;
    TextBox total;
    int j;

    public void create(object sender, EventArgs e)
    {
        i++;
         int TOTAL;
         TOTAL = 0;
        for ( j = 1; j <= i; j++)
        {

            tb = new TextBox();
            tb2 = new TextBox();
            total = new TextBox();
            tb.ID = j.ToString();
            Label lbl = new Label();
            lbl.Text = "Enter question";
           Panel1.Controls.Add(lbl);
           Panel1.Controls.Add(tb);
           Label l2 = new Label();
           l2.Text = "Enter Marks";
           Panel1.Controls.Add(l2);
           Panel1.Controls.Add(tb2);
           tb2.ID = "tb" + j;

           Panel1.Controls.Add(new LiteralControl("<br />"));
           Panel1.Controls.Add(new LiteralControl("<br />"));
        }

        Label res = new Label();
        res.Text = "Total Marks";
        Panel1.Controls.Add(res);
       total.Text = TOTAL.ToString();
        Panel1.Controls.Add(total);

    }

I want this When i insert value in marks textbox and press button addNew then value display in 3rd textbox again i insert value in marks textbox then sum of marks show in 3rd textbox

Related posts

Recent Viewed