locked
calling ByVal RRS feed

  • Question

  • User1717218719 posted

     I  have to byval variablename as SOMETHING. in this line If CType(e.CommandSource, LinkButton).CommandName = "UpdateRow" Then as im calling it in a button sub which has e as eventargs. how do I i do this ?

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Call UPDATEtoRepeater(argcmndsrc, TextBox1, TextBox2, TextBox3, TextBox4, CType(CType(rptTaxCom.Controls(rptTaxCom.Controls.Count - 1), RepeaterItem).FindControl("Label2"), Label), CType(CType(rptTaxCom.Controls(rptTaxCom.Controls.Count - 1), RepeaterItem).FindControl("Label3"), Label), CType(CType(rptTaxCom.Controls(rptTaxCom.Controls.Count - 1), RepeaterItem).FindControl("Label4"), Label), rptTaxCom)
    
    
    End Sub
    
    
    
    
    Protected Sub UPDATEtoRepeater(ByVal argcmndsrc As SOMETHING, ByRef argTxtBox1 As TextBox, ByRef argTxtBox2 As TextBox, ByRef argTxtBox3 As TextBox, ByRef argTxtBox4 As TextBox, ByRef argLbl2 As Label, ByRef argLbl3 As Label, ByRef argLbl4 As Label, ByRef argrpt As Repeater)
    
            Try
    
                Dim e As RepeaterCommandEventArgs = Nothing
    
                If CType(e.CommandSource, LinkButton).CommandName = "UpdateRow" Then
    
                    Dim intIdx As Integer = CType(e.CommandSource, LinkButton).CommandArgument
                    Dim itmRpt As RepeaterItem = argrpt.Items(intIdx)
    
                    '-- Validation - validate fields (integers/decimals)
                    Dim txtAir As TextBox = CType(itmRpt.FindControl("argTxtBox2"), TextBox)
    End Sub

    Monday, June 17, 2019 3:20 PM

All replies

  • User475983607 posted

     I  have to byval variablename as SOMETHING. in this line If CType(e.CommandSource, LinkButton).CommandName = "UpdateRow" Then as im calling it in a button sub which has e as eventargs. how do I i do this ?

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Call UPDATEtoRepeater(argcmndsrc, TextBox1, TextBox2, TextBox3, TextBox4, CType(CType(rptTaxCom.Controls(rptTaxCom.Controls.Count - 1), RepeaterItem).FindControl("Label2"), Label), CType(CType(rptTaxCom.Controls(rptTaxCom.Controls.Count - 1), RepeaterItem).FindControl("Label3"), Label), CType(CType(rptTaxCom.Controls(rptTaxCom.Controls.Count - 1), RepeaterItem).FindControl("Label4"), Label), rptTaxCom)
    
    
    End Sub
    
    
    
    
    Protected Sub UPDATEtoRepeater(ByVal argcmndsrc As SOMETHING, ByRef argTxtBox1 As TextBox, ByRef argTxtBox2 As TextBox, ByRef argTxtBox3 As TextBox, ByRef argTxtBox4 As TextBox, ByRef argLbl2 As Label, ByRef argLbl3 As Label, ByRef argLbl4 As Label, ByRef argrpt As Repeater)
    
            Try
    
                Dim e As RepeaterCommandEventArgs = Nothing
    
                If CType(e.CommandSource, LinkButton).CommandName = "UpdateRow" Then
    
                    Dim intIdx As Integer = CType(e.CommandSource, LinkButton).CommandArgument
                    Dim itmRpt As RepeaterItem = argrpt.Items(intIdx)
    
                    '-- Validation - validate fields (integers/decimals)
                    Dim txtAir As TextBox = CType(itmRpt.FindControl("argTxtBox2"), TextBox)
    End Sub

    The only event args in your example code are from a button click. There are no command button click event args.  Command button clicks are registered in the data bound control.

    https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.repeater.itemcommand?view=netframework-4.8

    I recommend reading the reference documentation before moving forward.  If you need help with your code then post all the relevant bits.

    Monday, June 17, 2019 3:40 PM