locked
Find control in formview RRS feed

  • Question

  • User-1959649351 posted

    Hey everyone,

    I'm working on an Insert action custom page.

    I'm asking a user to select an employee id from a dropdownlist and to select a file from a file upload control.

    I'm in need of accessing the selected value of the employee id to add to my path that I'm storing before the insert happens.

    How can I effectivly access the dropdown list to get this value?

    I've tried the FormView ItemInserting event (using FindControl) but I'm not sure if thats the correct way to go about this. 

    Thanks!

    Thursday, August 11, 2011 5:10 PM

Answers

All replies

  • User-1959649351 posted

    To add, this is what I have tried so far:

     Protected Sub FormView1_ItemInserting(sender As Object, e As System.Web.UI.WebControls.FormViewInsertEventArgs) Handles FormView1.ItemInserting
    
    
            Dim fieldTemplate = TryCast(FormView1.FindFieldTemplate("Employee Information"), FieldTemplateUserControl)
            If fieldTemplate IsNot Nothing Then
                Dim entryFldDescript = TryCast(fieldTemplate.DataControl, TextBox)
                Dim empid As String = entryFldDescript.Text
            End If
    
    End Sub
    Thursday, August 11, 2011 5:11 PM
  • User-330204900 posted

    Hi cyris|, have a look at my article here Communicating Between FieldTemplates in Dynamic Da...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 11, 2011 5:47 PM
  • User-1959649351 posted

    Hey Steve thanks for the reply.

    Lots of work!

    No simple way to just find the FieldTemplate and get the value on the form OnInserting event ?

    Wonder if I am just best to use a custom page...

    Friday, August 12, 2011 12:18 PM
  • User-330204900 posted

    not easily, plus if you make a change the UI would not reflect it. However if you do not need the UI to respond to the change the you could do what you need in the model.

    What Model are you using L2S, EF etc?

    Friday, August 12, 2011 1:20 PM
  • User3866881 posted

    To add, this is what I have tried so far:

     Protected Sub FormView1_ItemInserting(sender As Object, e As System.Web.UI.WebControls.FormViewInsertEventArgs) Handles FormView1.ItemInserting
    
    
            Dim fieldTemplate = TryCast(FormView1.FindFieldTemplate("Employee Information"), FieldTemplateUserControl)
            If fieldTemplate IsNot Nothing Then
                Dim entryFldDescript = TryCast(fieldTemplate.DataControl, TextBox)
                Dim empid As String = entryFldDescript.Text
            End If
    
    End Sub

    Hello:)

    Your codes look nice and it should work well. To simply it …… Hummm……

    Do you want to simplify it (you mean to shorten the codes or improve the speed? Do you think if it's too slow if you choose 2nd )

    Thx anyway

    Best Regards.

    Saturday, August 13, 2011 3:39 AM