REQUEST IN RETRIEVING VALUES FROM INPUT TYPE TEXTBOX

jayprakash sharma

Total Post:117

Points:821
Posted by  jayprakash sharma
 967  View(s)
Ratings:
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)
    {
        Session.Remove("clicks");
        i = 0;
    }
}
protected void GridView1_SelectedIndexChanged(object sender,EventArgs e)
{
    int rowCount = 0;
 
    rowCount =Convert.ToInt32(Session["clicks"]);
 
    rowCount++; 
    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>";
        i++;
}
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. Pravesh Singh

    Post:412

    Points:2888
    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

Answer

NEWSLETTER

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