Hope there's .NET developers here that could enlighten me up.
I actually already made up some pages in .NET environment, and i'm using VB.NET as my back-end.
Phewww....!
I have 2 files of A.ascx and B.ascx and each of them have the A.ascx.vb and B.ascx.vb files altogether.
But here's the interesting part. I use 'isEqual' variable inside one of the method I typed in. And if I use it inside one of the vb file then, I could not use it into another vb file. Thus, Once I used that 'isEqual' inside of these 2 vb (files), I will got the error appeared as from one of the vb file;
'isEqual' is not declared. It may be inaccessible due to its protection level.
Is there any alternative way out for this?
My code is actually this one;
Protected Sub bindTable()
'add somemore for searching with dropdown list
Dim sSql As String = "SELECT *, C.companyname FROM quotationmst Q"
Dim sColumn As String = Nothing
Dim sSearchField As String = Nothing
Dim sOptional As String = Nothing
If txtQuotationSearchField.Text.Length > 0 Then
sColumn = drpQuotationSearchField.SelectedItem.Value
sSearchField = " WHERE " & sColumn & " LIKE '%" & txtQuotationSearchField.Text & "%' "
sSql &= sSearchField
If isEqual(sColumn, "companyname") = 0 Or isEqual(sColumn, "customername") = 0 Then
sSearchField = " INNER JOIN customermst C on Q.customerid = C.customerid WHERE C." & sColumn & " LIKE '%" & txtQuotationSearchField.Text & "%'"
sSql &= sSearchField
End If
Else
sSearchField = " INNER JOIN customermst C ON Q.customerid = C.customerid"
sSql &= sSearchField
End If
Dim oCommon As New Common
sSql &= " ORDER BY quotationcode"
Dim dT As DataTable = oCommon.getDataSet(sSql)
dgRecord.DataSource = dT
dgRecord.DataBind()
lblTotal.Text = dT.Rows.Count
End Sub
Just do
If sColumn.Equals("companyname") Or sColumn.Equals("customername") Then
What I think is happening here is this:
When you create a file in Visual Studio (vb.net) and add a control using the designer it creates a file called "filename.aspx.designer.vb" You may have created the first page using the designer, and copied it to create the second page, losing the design file in that process.
This would give you the above error as the design file has auto generated field declarations in it, that look like this:
Protected WithEvents rptPackages As Global.System.Web.UI.WebControls.Repeater
In any case, try using the above declration for your vars, or at least make them "Protected" or "Public" so there is some kind of scope to them. Using dim can cause all kinds of runtime and compilation errors which are hard to diagnose because of type inferance.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.