request in retrieving values from input type textbox

Total Post:117

 1060  View(s)
Rate this:
having a problem in retrieving the values input at the input type. here is the code that we use... 
protected void Page_Load(object sender, EventArgs e)
    if (!Page.IsPostBack)
        i = 0;
protected void GridView1_SelectedIndexChanged(object sender,EventArgs e)
    int rowCount = 0;
    rowCount =Convert.ToInt32(Session["clicks"]);
    Session["clicks"] = rowCount;
    Literal1.Text =Literal1.Text + "PRODUCT: <input type='textbox' runat='server' id='textboxu" + i + "' value='" + GridView1.SelectedRow.Cells[1].Text + "' ></input> PRICE: <input type='textbox' runat='server' size='1' id='textboxe" + i + "' value='" + GridView1.SelectedRow.Cells[2].Text + "' ></input>QUANTITY:<input type='textbox' runat='server' size='1' id='textboxq" + i + "'></input>TOTAL:<input type='textbox' runat='server' size='3' id='total" + i + "' ></input><br>";
protected void Button1_Click(object sender, EventArgs e)
    for (int check =0; check <= i; check++)
        double price =Convert.ToDouble(this.Request.Form["textboxe" + i + ".Value"]);
        double quantity = Convert.ToDouble(this.Request.Form["textboxq" + i + ".Value"]);
        double total =price * quantity;
        TextBox1.Text= Convert.ToString(total);
        //this.Request.Form["total" + i] = Convert.ToString(total);

we need to retrieve the answer also from the input type. i hope there are someone who will be willing to help us...

  1. Post:412

    Re: request in retrieving values from input type textbox

    Hi Jay, 

    There is just slight change in syntax to get correct answer, see below snippet

     double price =Convert.ToDouble(Request.Form["textboxe" + i ]);
     double quantity =Convert.ToDouble(Request.Form["textboxq" + i]);
     double total = price* quantity;
     TextBox1.Text =Convert.ToString(total);
    //you need to use only request.Form rather than .value attribute string szValue =  Request.Form["txt1"]

    hope it helps

      Modified On Apr-07-2018 01:16:40 AM



Enter your email address here always to be updated. We promise not to spam!