Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find Control in EditCommand

Status
Not open for further replies.

vwhite

Programmer
Oct 4, 2001
87
0
0
AU
I am trying to find a control in the EditCommand of a datagrid.

I am using

Sub dgOutputs_Edit(sender as Object, e as DataGridCommandEventArgs)

Dim intOutput as int32 = Ctype(e.Item.FindControl("ddlOutput"), DropDownList).SelectedItem.Value
dgOutputs.EditItemIndex = e.Item.ItemIndex

End Sub

in the same way that I use it in the Update command but I cannot seem to reference the DropDownList.

Any clues??

Vicky....

"I used to have a handle on life...then it broke
 
The only reason for that error is that it is not finding that control with that name. Make sure the name is correct. Also, is it in a template column?

Jim
 
we seem to be making a habit of this!

There is definitely a control with that name, a drop down list. I use the exact same line in the update command. It is in a template column and it is in the Edit Column

Vicky....

"I used to have a handle on life...then it broke
 
System.NullReferenceException: Object reference not set to an instance of an object.


Vicky....

"I used to have a handle on life...then it broke
 
It's amazing what a good nights sleep can do.

It would seem that you cannot do this within the EditCommand that it has to be down within the OnItemDataBound Command. Then check
if e.Item.ItemType = ListItemtype.EditItem

Vicky....

"I used to have a handle on life...then it broke
 
Yes,.. that definatly makes sense.. glad you got it going..
Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top