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

Joined
Sep 13, 2006
Messages
1
Reaction score
0
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 :

Code:
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.DataBind()
            toSubSectDDL.Items.Insert(0, New ListItem("Select", "0"))
             Next
    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......

Thanks..
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top