I'm trying to call a base class specifically; Release class into a Page_load method.The release class is linked to a baseclass which contains a method Dataset Getresult.
How do i call from the release class into the page load.I'm using Repeater
I'm trying to do something like this

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
         //is this the correct way to do it?
        Release release = new Release();
        release.GetResult();// but GetResult() doesn't show when i try  to create it
       DataSet ds = new DataSet();
            da.Fill(ds);
            Repeater1.DataSource = ds;
           Repeater1.DataBind();
            

        }
}

Here's the code for GetResult()

protected DataSet GetResult()
        {
            SqlConnection scn = new SqlConnection(connect);
            SqlCommand spcmd = new SqlCommand(_sp, scn);
            spcmd.CommandType = CommandType.StoredProcedure;

            foreach (KeyValuePair<string, string> pair in sql_params)
            {
                spcmd.Parameters.AddWithValue(pair.Key, pair.Value);
            }

            Clear();
            SqlDataAdapter da = new SqlDataAdapter(spcmd);
            DataSet ds = new DataSet();
            
            scn.Open();
            da.Fill(ds);
            scn.Close();

            return ds;
        }

What do i need to do to call the method from GetResult into the page_load,do i need to declare a stored procedure and bind it to my html?

Your GetResult() method already returning DataSet, then why you are creating new object of DataSet and Filling it with the help of adapter and binding it to your repeater in page load event . Your code is totally wrong here.

You don't need to do anything. Just follow below code and it will work for you..

if (!IsPostBack)
{
        Release release = new Release();
        Repeater1.DataSource = release.GetResult();
        Repeater1.DataBind();
}

Let us know if it will not work you...

I'm trying to call a base class specifically; Release class into a Page_load method.The release class is linked to a baseclass which contains a method Dataset Getresult.
How do i call from the release class into the page load.I'm using Repeater
I'm trying to do something like this

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
         //is this the correct way to do it?
        Release release = new Release();
        release.GetResult();// but GetResult() doesn't show when i try  to create it
       DataSet ds = new DataSet();
            da.Fill(ds);
            Repeater1.DataSource = ds;
           Repeater1.DataBind();
            

        }
}

Here's the code for GetResult()

protected DataSet GetResult()
        {
            SqlConnection scn = new SqlConnection(connect);
            SqlCommand spcmd = new SqlCommand(_sp, scn);
            spcmd.CommandType = CommandType.StoredProcedure;

            foreach (KeyValuePair<string, string> pair in sql_params)
            {
                spcmd.Parameters.AddWithValue(pair.Key, pair.Value);
            }

            Clear();
            SqlDataAdapter da = new SqlDataAdapter(spcmd);
            DataSet ds = new DataSet();
            
            scn.Open();
            da.Fill(ds);
            scn.Close();

            return ds;
        }

What do i need to do to call the method from GetResult into the page_load,do i need to declare a stored procedure and bind it to my html?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.