using Find Control to manipulate individual rows in a datagrid.. HELp

Sep 13, 2006
Reaction score
Hi All..

i have been posting this in every ASP.NET forum I can find and read through numerous articles but no one has yet offered any help.. Hoping that I could find some help here.. Herez mi question..

I need help with a function that I have written for a selectedindexchange event of a drop down list which is embedded inside a datagrid..

The source code i have written is as below :

Protected Sub toSectDDL_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim row As DataGridItem
            For Each row In SectionGrid.Items
            Dim toSectDDL As DropDownList = CType(sender, DropDownList)
            Dim toSubSectDDL As DropDownList = CType(row.FindControl("toSubSectDDL"), DropDownList)
          Dim toSectID As Integer = CInt(toSectDDL.SelectedValue)
            Utilities.LogError("toSectID " & toSectID)
            toSubSectDDL.DataSource = Office.GetSubSectionsForSection(toSectID)
            toSubSectDDL.DataTextField = "subsection"
            toSubSectDDL.DataValueField = "subSecID"
            toSubSectDDL.Items.Insert(0, New ListItem("Select", "0"))
    End Sub

The thing is when i use row.FindControl the toSectDDLs in all the rows of the datagrid are affected whereas i want to manipulate the drop down list only on a single row.. When I try using SectionGrid.FindControl instead of the row.FindControl I get a server error saying "Object reference not set to an instance of an object. "

So anyone has any ideas plz do contribute......



Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question