0

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?

2
Contributors
1
Reply
3
Views
6 Years
Discussion Span
Last Post by rohand
0

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?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.