I have some Textbox controls on my page that are generated by a for-loop for each tuple from a database. Their IDs are textboxX where X is the counter from the for-loop.
Now, I activated postback for the textboxes, so that when the user changes the value in one of them, the page does a postback.
To handle the values from the postback, I test Page.IsPostBack. If this test is true, I want to use the new value (from the textbox that did the postback) to ie update the database. So far, I just loop through all the textboxes and update all the values (since I can't find out which control did the postback).
for (int i = 0; i < nAmountOfTextBoxes; i++)
int value; // value from textbox
value = int.Parse(((TextBox)myPanel.FindControl("textbox" + i.ToString())).Text);
// Couldn't parse
value = -1;
if (value >= 0)
deportToSiberia(value);// do something with the value
} // end for
This doesn't work. I didn't really expect it to, but I don't know any other way to go about with it. How can I fetch the values from a postback in my code? Any help is greatly appreciated.