views:

9

answers:

0

When DetailsView is in edit mode, it automatically displays ( inside its last row ) an Update button. We can find this button inside ItemCreated event handler using the following code:

  protected void dvwPoll_ItemCreated(object sender, EventArgs e)
  {
     foreach (Control ctl in dvwPoll.Rows[dvwPoll.Rows.Count - 1].Controls[0].Controls)
     {  
        if (ctl is LinkButton)
        {
           LinkButton lnk = ctl as LinkButton;
           if (lnk.CommandName == "Update"){...}             
        }
     }
  }

But why is the collection that contains the controls located within last row, accessed via dvwPoll.Rows[dvwPoll.Rows.Count - 1].Controls[0].Controls and not via dvwPoll.Rows[dvwPoll.Rows.Count - 1].Controls?

In other words, if dvwPoll.Rows[dvwPoll.Rows.Count - 1].Controls[0].Controls contains controls displayed in the last row, then what controls does Rows[dvwPoll.Rows.Count - 1].Controls[1].Controls contain?

thanx