none
The name 'grdWorkOrders' does not exist in the current context

    Question

  • Could someone please tell me why I am getting the above error?

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using NBSWorkOrder.BusinessLogic; using NBSWorkOrder.DataAccess; using NBSWorkOrder.Classes; using System.Xml; using System.Xml.Linq; using System.Data.SqlClient; namespace NBSWorkOrder { public partial class WorkOrder : System.Web.UI.Page { private DataTable dtblWorkOrder; // private DataSet dsWorkOrders; protected void Page_Load(object sender, EventArgs e) { Session["WorkOrder_wk_acct"] = null; dtblWorkOrder = NBSWorkOrderBusinessLogic.GetWorkOrderDatatable(); Session["WorkOrdersToSort"] = dtblWorkOrder.DefaultView; if (!Page.IsPostBack) { BindWorkOrders(); } } void BindWorkOrders() {

    // the error is here grdWorkOrders.DataSource = Session["WorkOrdersToSort"]; grdWorkOrders.DataBind(); } } }


    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="NBSWorkOrder._default" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>NBS Work Ordersxxx</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div style="vertical-align:top; height: 480px;  width:700px;">
    
            <asp:GridView ID="grdWorkOrders" AllowSorting = "true" OnSorting ="grdWorkOrders_Sorting" runat="server" AutoGenerateColumns ="false" AutoGenerateSelectButton ="true">
               <Columns>
                    <asp:BoundField ItemStyle-Width="100px" DataField="wk_acct" HeaderText="Account" SortExpression="Account" />
               </Columns>
    
    
            </asp:GridView>
    
        </div>
        </form>
    </body>
    </html>

    eone please tell me why I am getting:The name 'grdWorkOrders' does not exist in the current context
    eone please tell me why I am getting:The name 'grdWorkOrders' does not exist in the current context

    DrewT1755



    • Edited by DrewT1755 Wednesday, September 21, 2016 4:06 PM
    Wednesday, September 21, 2016 4:01 PM

Answers

  • I think that the values of CodeBehind and Inherits attributes are incorrect. Probably should be CodeBehind=”WorkOrder.aspx.cs” Inherits=”NBSWorkOrder.WorkOrder”. If the first part of the code is default.aspx.cs, then fix the value of Inherits only.

    Better to avoid manual editing, and to let Visual Studio to create the new pages using usual procedures.


    • Edited by Viorel_MVP Wednesday, September 21, 2016 5:52 PM
    • Marked as answer by DrewT1755 Wednesday, September 21, 2016 6:24 PM
    Wednesday, September 21, 2016 5:48 PM

All replies

  • I think that the values of CodeBehind and Inherits attributes are incorrect. Probably should be CodeBehind=”WorkOrder.aspx.cs” Inherits=”NBSWorkOrder.WorkOrder”. If the first part of the code is default.aspx.cs, then fix the value of Inherits only.

    Better to avoid manual editing, and to let Visual Studio to create the new pages using usual procedures.


    • Edited by Viorel_MVP Wednesday, September 21, 2016 5:52 PM
    • Marked as answer by DrewT1755 Wednesday, September 21, 2016 6:24 PM
    Wednesday, September 21, 2016 5:48 PM
  • Hi @Viorel_,

    Thank your for sharing such a good solution here.

    Have a nice day!

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

    Click HERE to participate the survey.

    Thursday, September 22, 2016 1:44 AM
    Moderator