GridView.Rows.Count & EditIndex

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mike0870
    New Member
    • Aug 2007
    • 1

    #1

    GridView.Rows.Count & EditIndex

    Hi, I've been at this one for hours and cannot not find any posts of anyone having the same problem. Ther scenario is, I need to fill a drop down box with a value in the grid row to pass to the select statement whcih returns the rows to the drop down.

    Its the problem is happening in the ObjectDataSourc e_Selecting Event of the dropdown control when the Edit command is clicked for a grid row. I'm using the syntax , GridView.rows[EditIndex].FindControl[control with the value i need]
    to get the value to pass to the object source for the drop down.

    If i hit the edit link of the first row of a paged grid view, the [gridview].rows.count = 0

    IF i attempt to edit the second row, the rows count is now 1, the third row, the row count is 2 and so on.

    So 2 problems. If I try to get a reference to the control in the first row after the gridview goes into edit mode, I can't since the gridview.rows.c ount returns 0.

    If I try to get a reference to controls in any other row besides the first, I get the controls in the previous row to the one I selected for editing. So If I click the edit command for row 3, and try to access a control (a bound textbox) in that row using [gridview].rows[editIndex-1] i get the value of the corresponding control from row 2.

    FuIn addition, If I try to use editindex (Without the -1) i get an index out of range exception. So the grid view row count always seems to equal to the value for [gridview].editindex.

    I am using a collection as a datasource.
Working...