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.
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.