Hi I have created no. of textboxes(that no entered by user in txtcount textbox) dynamically. But i want to store those values into database. For that i used code in save button click event as follows :
protected void btnsave_Click(object sender, EventArgs e)
{
// Check how many textboxes the user created
int count = Convert.ToInt32(txtcount.Text);
// Loop through them
for (int i=0; i < count; i++)
{
// Get the TextBox
TextBox textbox = (TextBox)Page.FindControl("TextBox_" + i);
// Get the value
string val = textbox.Text;
Response.Write(val);
}
}
But its giving error :
Object reference not set to an instance of an object.
What should i do? Please help me? Thank you.