DataGridItem.FindControl()

J

John Smith

I'm using this code:

Public Sub DropDown_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs)
Dim list As DropDownList = CType(sender, DropDownList)
Dim cell = CType(list.Parent, TableCell)
Dim item = CType(cell.Parent, DataGridItem)
Dim index = item.ItemIndex
Dim row As DataRow
row = ds.Tables(0).Select("ID = '" + item.Cells(0).Text + "'")(0)
row.Item("Status") = list.SelectedValue
row.AcceptChanges()
If row.Item("Status") = "D" Then
item.FindControl("txtMyText").ReadOnly = False
or
cell.FindControl("txtMyText").ReadOnly = False
or
item.Parent.FindControl("txtMyText").ReadOnly = False

The problem is that DropDownList that triggers above Sub is not in the same
datagrid cell as txtMyText. However, it is in the same row. How can I get
reference on it (txtMyText)? All 3 above FindControl() calls fail with:

[NullReferenceException: Object variable or With block variable not set.]

There are no problems with finding controls that are in the same cell as
DropDownList which triggered above event.
 

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,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top