I have a querystring.aspx file having a gridview inside in it.
In querystring.cs file's default class that is
public partial class querystring : System.Web.UI.Page
,
i can access the gridview
control id.I have made a another class below this class ,but it is not accessing the gridview
control id.
This is user defined class code in querystring.cs file:-
public partial class bindingmethod : System.Web.UI.Page
{
public void show()
{
SqlConnection con = new SqlConnection(getconnectionstring());
SqlCommand cmd = new SqlCommand();
DataTable dt = new DataTable();
cmd.Connection = con;
con.Open();
SqlDataAdapter adb = new SqlDataAdapter("show_answers", con);
adb.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
//Get a connection string to make a db connection
public static string getconnectionstring()
{
return System.Configuration.ConfigurationManager.ConnectionStrings["crudconnection1"].ConnectionString;
}
}
For GridView1 it says:
The name GridView1 does not exist in the current context.
Please help me. Thank you.