Home > DeveloperSection > Forums > request in retrieving values from input type textbox
jayprakash sharma
jayprakash sharma

Total Post:117

Points:821
Posted on    November-27-2014 12:57 AM

 ASP.Net ASP.Net 
Ratings:


 1 Reply(s)
 528  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)

    {

        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...



Pravesh Singh

Total Post:411

Points:2881
Posted on    November-27-2014 1:52 AM

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


Don't want to miss updates? Please click the below button!

Follow MindStick