Re: Need help with FindControl in DataGrid

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Okay, now i've got my code completely working. I wish I better
understood the scope of the various ways of doing it (cells vs. items,
etc). Anyhow, here's the completed code for the Edit event. Notice the
last 2 lines concerning the label. I'm taking the value from the label
in the Normal Template and using it to change the SelectedValue in the
DropDownList. Is this the "preferred" way, or is there a better way (as
was pointed out earlier in this thread) of finding the Label Control?

Private Sub DataGrid1_EditCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
DataGrid1.EditCommand
DataGrid1.EditItemIndex = e.Item.ItemIndex
btnAddServer.Visible = False
LoadGrid()
Dim ddl As DropDownList =
CType(DataGrid1.Items(e.Item.ItemIndex).FindControl("ddl3"),
DropDownList)
For i As Integer = 0 To ddlTechs.Items.Count - 1
ddl.Items.Add(ddlTechs.Items.Item(i).Value)
Next
Dim lb As Label = CType(e.Item.Cells(3).FindControl("Label3"),
Label)
ddl.SelectedValue = lb.Text
End Sub

*** Sent via Developersdex http://www.developersdex.com ***
.



Relevant Pages

  • RE: Control Tip Text Question
    ... --You didnt try the frame control..No problems. ... ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) ... Private Sub CheckBox470_MouseMove(ByVal Button As Integer, ... i only want the label to be seen if mouse is over the checkbox. ...
    (microsoft.public.excel.programming)
  • Re: Floating Box for Prices
    ... (to trigger your floating window for example). ... Label control indicates when the "mouse down for a specified period" has ... Private tDown As Single, counting As Boolean ... Private Sub Picture1_MouseDown(Button As Integer, ...
    (microsoft.public.vb.general.discussion)
  • Re: A HELP BOX
    ... lblDescriptive is the name of the descriptive label placed near the textbox. ... Private Sub UserForm_Initialize ... 'Show the decriptive label on entry to the text field. ... name, CtrlTab twice, your Middle Initial, CtrlTab once, Last Name""" ...
    (microsoft.public.word.vba.general)
  • Re: Floating Box for Prices
    ... Often with things like floating information windows it is best to use a "hover period" so that the window appears if the user simply hovers the mouse in one spot for more than a predetermined period. ... The Label control indicates when the "mouse down for a specified period" has been activated and the Label disappears as soon as the user then lets go of the mouse button (the Label is just an indication of course, and you would simply modify the code to instead show your little floating "follow the mouse" information window. ... Private tDown As Single, counting As Boolean ... Private Sub Picture1_MouseDown(Button As Integer, ...
    (microsoft.public.vb.general.discussion)
  • Re: Take a sting and set it as text in a userform label
    ... You could use the UserForm Initialize event and set the value of the ... label caption to a table cell text. ... Private Sub UserForm_Initialize ... To be more specific, I am reading cells ...
    (microsoft.public.word.vba.general)