CommonClass.cs中的错误名称'gvwBoarding'在当前上下文中不存在 [英] Error in CommonClass.cs the name 'gvwBoarding' doesnot exist in current context

查看:86
本文介绍了CommonClass.cs中的错误名称'gvwBoarding'在当前上下文中不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CommonClass.cs Error raising on this page
Error: The name 'gvwBoarding' doesnot exist in current context.

BusRouterHeader.aspx.cs
gvwBoarding is a Gridview id in BusRouterHeader.aspx.cs page


protected void btnSave_Click(object sender, EventArgs e)
       {
           string re = "Given Field is Empty";
           if (ddlBusTravelsName.SelectedIndex.ToString() != "0" && txtAmount.Text != "" && txtFromCity.Text != "" && txtToCity.Text != "" && txtDepartureTime.Text != "" && txtArrivelTime.Text != "")
           {
               DoFill();
               string res = CC.DoInsertBusRHeader(B);
               ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + res + "');", true);
               Clear();
               CC.DoGdviewBoarding(); //I will call this method...... 
               
           }
           else
           {
               ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + re + "');", true);
           }
       }

CommonClass.cs
public void DoGdviewBoarding()
        {
            SqlCommand cmd;
            try
            {
                SqlDataAdapter sda;
                DataSet ds;
                mDbconnection = conn.GetDefaultDbConnectionString();
                cmd = new SqlCommand("[DBO].[Proc_GetBoarding]", mDbconnection);
                cmd.CommandType = CommandType.StoredProcedure;
                sda = new SqlDataAdapter(cmd);
                ds = new DataSet();
                sda.Fill(ds, "BusRouterHeaderMaster");
                gvwBoarding.DataSource = ds;
                gvwBoarding.DataBind();
                mDbconnection.Close();
            }
            catch (Exception e)
            {

            }
            finally
            {
                if (cmd != null)
                    cmd.Dispose();
                cmd = null;
                mDbconnection.Close();
            }
        }

推荐答案

我猜你在其他地方定义了 gvwBoarding 。所以找到它的实例在你的 CommonClass.cs 中使用它。
I guess you were defined gvwBoarding somewhere else. so find the instance of it use it in your CommonClass.cs.


这篇关于CommonClass.cs中的错误名称'gvwBoarding'在当前上下文中不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆