Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'll try to explain my problem in the easiest way I can, since even for me it is difficult to understand.

I've created a custom web part in which I have two columns: a datalist and a few buttons on the left, and my reportviewerwebpart on the right.

I've created a class to build my custom reportviewerwebpart, code below:

public class CCReport : ReportViewerWebPart
{
    private string herdId;
    private string prvCd;
    private string breed;
    private string heifer;
    private string reportType;
    private ReportParameterDefaultCollection paramCollection;

    public string HerdId
    {
        get
        {
            return this.herdId;
        }
        set
        {
            this.herdId = value;
            paramCollection.Add(new Microsoft.Reporting.WebForms.ReportParameter("herdId", herdId));
        }
    }
    public string PrvCd
    {
        get
        {
            return this.prvCd;
        }
        set
        {
            this.prvCd = value;
            paramCollection.Add(new Microsoft.Reporting.WebForms.ReportParameter("prvCd", prvCd));
        }
    }
    public string Breed
    {
        get
        {
            return this.breed;
        }
        set
        {
            this.breed = value;
            paramCollection.Add(new Microsoft.Reporting.WebForms.ReportParameter("race", breed));
        }
    }
    public string Heifer
    {
        get
        {
            return this.heifer;
        }
        set
        {
            this.heifer = value;
            if (this.heifer != null)
                paramCollection.Add(new Microsoft.Reporting.WebForms.ReportParameter("visibleId", heifer));
        }
    }
    public string ReportType
    {
        get
        {
            return this.reportType;
        }
        set
        {
            this.reportType = CCConstants.REPORT_PATH + value + ".rdl";
            this.ReportPath = this.reportType;
        }
    }

    public CCReport() { }

    public CCReport(string reportType, string herdId, string prvCd, string breed, string heifer = null)
    {
        paramCollection = new ReportParameterDefaultCollection();
        paramCollection = this.OverrideParameters;
        this.ChromeType = System.Web.UI.WebControls.WebParts.PartChromeType.None;
        //this.PromptAreaMode = CollapsibleDisplayMode.Hidden;
        this.Height = "693";
        this.HerdId = herdId;
        this.PrvCd = prvCd;
        this.Breed = breed;
        this.Heifer = heifer;
        this.ReportType = reportType;
    }
}

When I open the webpart this is my LOAD:

protected void Page_Load(object sender, EventArgs e)
    {
        SPWeb web = SPControl.GetContextWeb(Context);
        //user = new CCUser(web.CurrentUser, Request.QueryString["noTRO"], Request.QueryString["prv_cd"]);
        user = new CCUser(web.CurrentUser, "2633", "04");

        // Get user's race types and bind to the DropDownListRaces 
        if (!this.IsPostBack)
        {
            DropDownListRaces.DataTextField = "Value";
            DropDownListRaces.DataValueField = "Key";
            DropDownListRaces.DataSource = user.breeds;
            DropDownListRaces.DataBind();
            DropDownListRaces.AutoPostBack = true;
            DropDownListRaces.SelectedIndex = 0;
        }

        rv = new CCReport();
        hg = new CCHeifersGrid();

        // events
        hg.SelectedIndexChanged += new EventHandler(heifers_SelectedIndexChanged);
        hg.SortCommand += new DataGridSortCommandEventHandler(heifers_SortCommand);
        //DropDownListRaces.SelectedIndexChanged += new EventHandler(DropDownListRaces_SelectedIndexChanged);
        RadioButtonListReportType.SelectedIndexChanged += new EventHandler(RadioButtonListReportType_SelectedIndexChanged);

        // heifers grid
        hg.DataSource = user.getAnimalsByRace(DropDownListRaces.SelectedValue);
        hg.DataBind();
        PanelHeifers.Controls.Add(hg);

        // reportview
        rv = new CCReport(RadioButtonListReportType.SelectedValue, user.herd.id, user.herd.prv_cd, DropDownListRaces.SelectedValue);

        PanelReport.Controls.AddAt(0, rv);
        UpdatePanelReport.Update();


    }

MY PROBLEM:

First time entering the webpart: it doesn't load the graphic(report) even though I can see my parameters on my PromptAreaMode. I have to to change my dropdownlist (postback = true), so it shows up on the page, but... after every change I do on my dropdownlist, it must also changes the report. It doesn't even change the parameters on the PromptAreaMode, even though when debugging I can see that the change is done correctly.

PLEASE CAN SOMEONE HELP ME? I need to finish this!

Thank you!!!

share|improve this question
    
Can you clarify a bit, please. It sounds like you said you have a custom webpart, and inside the web part, there is yet another custom web part that inherits from reportviewerwebpart. Or, are you describing a single custom reportviewerwebpart which features a datalist and buttons to one side? –  bkwdesign Oct 19 '12 at 16:25
    
My first thought is that you need to understand when to override CreateChildControls and OnPreRender. In my limited experience building custom web parts in Visual Studio, these are crucial to controlling the state of things and Page_Load is something left to traditional ASPX development and not appropriate for this scenario. –  bkwdesign Oct 19 '12 at 16:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.