Click here to Skip to main content
15,903,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
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();
            }
        }
Posted
Updated 16-Mar-14 22:05pm
v6
Comments
Krunal Rohit 17-Mar-14 3:40am    
Where are you calling this method ??

-KR
Krunal Rohit 17-Mar-14 3:45am    
I mean on which event ?

-KR
sridharan.N 17-Mar-14 4:14am    
Hello sir, i will updated my question reply me sir
Krunal Rohit 17-Mar-14 5:50am    
can you paste the very first line of .aspx page and the entire asp.cs ??

-KR

1 solution

I guess you were defined gvwBoarding somewhere else. so find the instance of it use it in your CommonClass.cs.
 
Share this answer
 

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