Click here to Skip to main content
14,934,895 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am calling tb1_DataBinding but it gives error in VB use raise event...

In This Line
C#
tb1.DataBinding += New EventHandler(AddressOf tb1_DataBinding)


gives error DataBinding is an event and can not be called directly use raiseevent statement.
and text Box is Gridview control for bind data in it because GridView having dynamic editable column.

Link in C# :

[^]

But when I convert It in VB it gives error.

What I have tried:

VB
Dim tb1 As New TextBox()
                'Allocates the new text box object.

                tb1.DataBinding.Add += New EventHandler(AddressOf tb1_DataBinding)



 Private Sub tb1_DataBinding(sender As Object, e As EventArgs)
        Dim txtdata As TextBox = DirectCast(sender, TextBox)
        Dim container As GridViewRow = DirectCast(txtdata.NamingContainer, GridViewRow)
        Dim dataValue As Object = DataBinder.Eval(container.DataItem, _columnName)
        ' If dataValue <> DBNull.Value Then
        txtdata.Text = dataValue.ToString()
        ' End If
    End Sub
Posted
Updated 17-May-16 2:54am
v4
Comments
Dave Kreskowiak 17-May-16 8:46am
   
And the error message would be ....... ? Hint: The most important piece of information you can use to troubleshoot the problem.
   
What is TextBox? which one? Full type name, please...
There is the event System.Web.UI.Control.DataBinding, its definition matches your use.
—SA

1 solution

That looks like poorly-converted C# code. In VB.NET, you use AddHandler[^] to add a handler to an event:
VB.NET
AddHandler tb1.DataBinding, AddressOf tb1_DataBinding
   
Comments
Member 11449483 17-May-16 9:05am
   
Thanks Very Much.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900