我刚接手一个asp.net/vb网站,我肯定还在学习。我收到以下错误:BC30451:未声明'ByOwner'。由于其保护级别,它可能无法访问。
我用:
调用数据源<asp:GridView ID="CaseCountByOwner" runat="server" AllowSorting="true" DataSourceID="ByOwner"
以下是代码文件中的内容:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
HitMe.AddHit(Request.UserHostAddress, Request.UserAgent, Request.Url.ToString)
Dim user As String = Request.QueryString("user")
If user.Length() = 0 Then
Return
Else
ByOwner.SelectCommand = "select " & _
"TU.login_name as Owner," & _
"( select " & _
" count(1)" & _
"from table_case TC1 with (NOLOCK) " & _
"join table_user TU1 with (NOLOCK) on TU1.objid = TC1.case_owner2user " & _
"join table_gbst_elm TGE1 with (NOLOCK) on TGE1.objid = TC1.casests2gbst_elm " & _
"where TC1.case_wip2wipbin Is Not null " & _
"and TC1.x_casetype not in ('Esc- Support','CRel - Wellness') " & _
"and TU1.login_name = TU.login_name " & _
"and TGE1.title not in ('File CR') " & _
") as AllCases," & _
"( select " & _
"count(1)" & _
"from table_case TC2 with (NOLOCK) " & _
"join table_user TU2 with (NOLOCK) on TU2.objid = TC2.case_owner2user " & _
"join table_gbst_elm TGE2 with (NOLOCK) on TGE2.objid = TC2.casests2gbst_elm " & _
"where TC2.case_wip2wipbin Is Not null " & _
"and TC2.x_casetype not in ('Esc- Support','CRel - Wellness') " & _
"and TGE2.title not in ('File CR','Suggested Resolution','Suggestion Filed','Await SW Rel/Dev','Pending ClientAction') " & _
"and TU2.login_name = TU.login_name" & _
") as Workable," & _
"( select " & _
"count(1)" & _
"from table_case TC3 with (NOLOCK) " & _
"join table_user TU3 with (NOLOCK) on TU3.objid = TC3.case_owner2user " & _
"join table_gbst_elm TGE3 with (NOLOCK) on TGE3.objid = TC3.casests2gbst_elm " & _
"join table_gbst_elm SEVERITY3 with (NOLOCK) on TC3.respsvrty2gbst_elm = SEVERITY3.objid " & _
"where TC3.case_wip2wipbin Is Not null " & _
"and TC3.x_casetype not in ('Esc- Support','CRel - Wellness') " & _
"and SEVERITY3.title in ('Down','Critical - ANF') " & _
"and TGE3.title not in ('File CR','Suggestion Filed','Await SW Rel/Dev','Pending ClientAction') " & _
"and TU3.login_name = TU.login_name" & _
") as DownCritical, " & _
"( select " & _
"count(1)" & _
"from table_case TC4 with (NOLOCK) " & _
"join table_user TU4 with (NOLOCK) on TU4.objid = TC4.case_owner2user " & _
"join table_gbst_elm TGE4 with (NOLOCK) on TGE4.objid = TC4.casests2gbst_elm " & _
"where TC4.case_wip2wipbin Is Not null " & _
"and TC4.x_casetype not in ('Esc- Support','CRel - Wellness') " & _
"and TGE4.title in ('Testing Data') " & _
"and TU4.login_name = TU.login_name" & _
") as TestingData " & _
"from table_user TU with (NOLOCK)" & _
"where TU.login_name in (select TU.login_name from table_employee TE with (NOLOCK) " & _
"join table_user TU with (NOLOCK) on TE.employee2user = TU.objid and TU.status = 1 " & _
"where TE.emp_supvr2employee = (select EMPTE.emp_supvr2employee " & _
"from table_user EMPTU with (NOLOCK) " & _
"join table_employee EMPTE with (NOLOCK) on EMPTE.employee2user = EMPTU.objid " & _
"where EMPTU.login_name like ('" & user & "') " & _
")) " & _
"order by 1 "
End If
End Sub
Dim casesTotal As Integer = 0
Dim workableTotal As Integer = 0
Dim downTotal As Integer = 0
Dim testingTotal As Integer = 0
Protected Sub CaseCountByOwner_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
casesTotal += (DataBinder.Eval(e.Row.DataItem, "AllCases"))
workableTotal += (DataBinder.Eval(e.Row.DataItem, "Workable"))
downTotal += (DataBinder.Eval(e.Row.DataItem, "DownCritical"))
testingTotal += (DataBinder.Eval(e.Row.DataItem, "TestingData"))
ElseIf e.Row.RowType = DataControlRowType.Footer Then
e.Row.Cells(0).Text = "Totals:"
e.Row.Cells(1).Text = casesTotal
e.Row.Cells(2).Text = workableTotal
e.Row.Cells(3).Text = downTotal
e.Row.Cells(4).Text = testingTotal
e.Row.Font.Bold = True
End If
End Sub
Protected Sub UpdateTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
LiveQueue.DataBind()
LabelLiveQueue.Text = "Updated: " + DateAndTime.Now.ToString()
End Sub
Protected Sub UpdateTimer2_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
LiveAgents.DataBind()
LabelLiveAgents.Text = "Updated: " + DateAndTime.Now.ToString()
End Sub
Dim callsTotal As Integer = 0
Dim offeredTotal As Integer = 0
Dim handledTotal As Integer = 0
Protected Sub LiveQueueGridView_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
callsTotal += (DataBinder.Eval(e.Row.DataItem, "Holding"))
offeredTotal += (DataBinder.Eval(e.Row.DataItem, "Offered"))
handledTotal += (DataBinder.Eval(e.Row.DataItem, "Handled"))
ElseIf e.Row.RowType = DataControlRowType.Footer Then
e.Row.Cells(0).Text = "Totals:"
e.Row.Cells(1).Text = callsTotal
e.Row.Cells(3).Text = offeredTotal
e.Row.Cells(4).Text = handledTotal
e.Row.Font.Bold = True
End If
End Sub
Dim TotalCalls As Int32 = 0
Function GetCalls(ByVal Calls As Int32) As Int32
TotalCalls += Calls
Return Calls
End Function
Function GetTotal() As Int32
Return TotalCalls
End Function
Protected Sub BtnExportGrid_Click(ByVal sender As Object, ByVal args As EventArgs)
' pass the grid that for exporting ...
Me.CaseView.GridLines = GridLines.Both
GridViewExportUtil.Export("Cases.xls", Me.CaseView)
End Sub
结束班
非常感谢任何帮助,更值得赞赏的是一个关于开始使用.net应用程序的良好资源的链接。
答案 0 :(得分:1)
您需要在页面中的某处SqlDataSource
使用ID“ByOwner”
例如:
<asp:SqlDataSource ID="ByOwner" runat="server" />
请注意,您声明GridView的数据源为“ByOwner”。
答案 1 :(得分:1)
我建议你使用SP,而不是在sql中编写硬编码查询,你可以编写存储过程,这将给出最佳结果。
答案 2 :(得分:0)
您需要找到声明对象ByOwner
的位置。是否有一个控件在同一页上具有ByOwner的ID属性?