romit Posted July 7, 2011 Posted July 7, 2011 ((TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text I am using this line of code to access the value of textbox which appeared when i clicked on auto generated edit button in gridview. It is working fine. But my question is that what Controls[0] represents here? By the syntax it is looking like a collection whose zeroth control is being accessed by me. Then in what scenario would there be need to use Controls[1], Controls[2] ?? Quote
Administrators PlausiblyDamp Posted July 7, 2011 Administrators Posted July 7, 2011 Just about any container that can hold controls exposes them as a .Controls collection. If the cell only has a single control (the TextBox in your example) then Controls[0] will be the first and only control. If on the other hand there was more than one control in the cell then you would be able to use Controls[1] etc to refer to these other controls. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.