Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
protected void btnOrder_Click(object sender, EventArgs e)
        {          
            try                 
            {              
            

                    foreach (GridViewRow IgvRow in MomuGridView.Rows)
                     {                        
                            DataRow drI = dtGridView.NewRow();
                            string h = IgvRow.Cells[0].Text;
                            string k = IgvRow.Cells[1].Text;
                            string y = IgvRow.Cells[2].Text;
                            string hTT = IgvRow.Cells[3].Text;
                            string RR = IgvRow.Cells[4].Text;
                            string yTT = IgvRow.Cells[5].Text;
                            string hEE = IgvRow.Cells[6].Text;
                         //   TextBox txt = (TextBox)MomuGridView.Rows[intCnt].FindControl("myTextBox6");
                            string kWW = IgvRow.Cells[7].Text;
                            string yWW = IgvRow.Cells[8].Text;
                        
                    }
Posted
Updated 4-Jul-15 4:07am
v2
Comments
DamithSL 4-Jul-15 10:09am    
How you add textboxes?
Dave Kreskowiak 4-Jul-15 10:56am    
What do you mean by "dynamic textboxes" and how do they relate to this problem?

1 solution

This kind of issues generally happens with dynamically created controls but it's not an issue actually, rather it's the expected result according to asp.net page life cycle. The control state of dynamically created controls are not saved in view state. So on next post back it loses the state of all dynamically created controls.

The simplest solution to resolve the problem is to re create the controls with same Id on page post back.

Also, you need to write code something like the line you have commented to find the text boxes.

If anything more is required please let me know.

Hope, it helps :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900