cmcormick
asked on
Loop through rows to get control value within nested gridview ASP.NET 2.0
Scenario: Gridview with employee, nested gridview with tasks that require completion, an item template within nested gridview that has a dropdown box where the user selects whether the task is completed, in process, not started, etc. An update button in the employee item tempate field (in same cell as nested gridview) that houses the nested gridview. When the update button is clicked, I want to iterate through the nested gridview and get the new value of the dropdownlist and send it to the database.
Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim gvInside As GridView = CType(FindControl("gvTasks "), GridView)
Dim iStatus As Integer
Dim StatusBox As DropDownList
For Each row As GridViewRow In gvInside.Rows
StatusBox = CType(FindControl("ddCompl etionStatu s"), DropDownList)
iStatus = StatusBox.SelectedValue
Next
End Sub
The code above generates the following error: System.NullReferenceExcept ion was unhandled by user code Message="Object reference not set to an instance of an object."
Any help is appreciated. Thank you!
Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim gvInside As GridView = CType(FindControl("gvTasks
Dim iStatus As Integer
Dim StatusBox As DropDownList
For Each row As GridViewRow In gvInside.Rows
StatusBox = CType(FindControl("ddCompl
iStatus = StatusBox.SelectedValue
Next
End Sub
The code above generates the following error: System.NullReferenceExcept
Any help is appreciated. Thank you!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.