locked
Repeater not databinding after linq query RRS feed

  • Question

  • I have the following code which filters a list of 15 records out of a possible 95. I have verified by looking at the results in "q", that there are 15 records.

    When the DataBind occurs, the first record of "e" comes thru fine, but subsequent records of "e" are null causing an exception. Has anyone had this problem binding using the repeater control when the first record is ok, but subsequent records are not?

    When I have the code commented out in the ItemDataBound event, all 15 records display fine on the page. When I don't have the code commented out, it can't find anything on the FindControl subsequent times thru after the first record because the subsequent records of e is null.

    What gives???

    <code>

            private void SetDishProducts(List<DishRedesignClient.WcfDishDBService.FormSKUXRef> lstFormSKUXRef)
            {
                var q = from xref in lstFormSKUXRef
                        where xref.SKUType == "Programming"
                        orderby xref.PromoPackage descending, xref.Price
                        select new { xref.FormID, xref.ProductName, xref.Description, xref.Price, xref.FormSKUXREFID };

                Repeater1.DataSource = q;
                Repeater1.DataBind();
            }

            public void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
            {
                //ImageButton imgbtn1 = e.Item.FindControl("btnSelectPkg") as ImageButton;
                //AsyncPostBackTrigger trig1 = new AsyncPostBackTrigger();
                //trig1.ControlID = imgbtn1.UniqueID.ToString();
                //trig1.EventName = "Click";
                //UpdatePanel1.Triggers.Add(trig1);

                //ImageButton imgbtn2 = e.Item.FindControl("btnChannels") as ImageButton;
                //AsyncPostBackTrigger trig2 = new AsyncPostBackTrigger();
                //trig2.ControlID = imgbtn2.UniqueID.ToString();
                //trig2.EventName = "Click";
                //UpdatePanel1.Triggers.Add(trig2);

                //AjaxControlToolkit.ModalPopupExtender mpe1 = pnlChannels.FindControl("pnlChannels_ModalPopupExtender") as AjaxControlToolkit.ModalPopupExtender;
                //mpe1.TargetControlID = imgbtn2.UniqueID;

                //ImageButton imgbtn3 = e.Item.FindControl("btnPkgFeatures") as ImageButton;
                //AsyncPostBackTrigger trig3 = new AsyncPostBackTrigger();
                //trig3.ControlID = imgbtn3.UniqueID.ToString();
                //trig3.EventName = "Click";
                //UpdatePanel1.Triggers.Add(trig3);

                //AjaxControlToolkit.ModalPopupExtender mpe2 = pnlFeatures.FindControl("pnlFeatures_ModalPopupExtender") as AjaxControlToolkit.ModalPopupExtender;
                //mpe2.TargetControlID = imgbtn3.UniqueID;
            }
    </code>


    Bill Yeager
    Wednesday, October 14, 2009 11:01 PM

Answers