I am trying to loop through a comma delimited string. each on i want to get the value of the textbox after i click the update link in a c# datagrid. The code i have will run the first time around but when i get to 2 it stop and gives me the error:
n: Unable to cast object of type 'System.Web.UI.WebControls
to type 'System.Web.UI.WebControls
I know this is becuase I have to somehow change the name of the textbox from txt each time. does anyone know how to solve this problem?
for (int i = 1; i <= strArray.Length; i++)
TextBox txt = (TextBox)row.Cells[i].Controls;
Update = Update + " " + strArray[i].ToString() + "=" + txt.Text + ",";