Jump to content
Xtreme .Net Talk

((TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text


Recommended Posts

Posted

((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] ??

  • Administrators
Posted
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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...