将列表数据绑定到转发器控件

时间:2013-09-12 13:50:30

标签: asp.net c#-4.0

My Repeater 我想要做的是我想绑定我对转发器控件的响应。 在响应中有名称,问题,免责声明等字段。我想将这些字段数据绑定到转发器中的控件。

我在做的是:

 protected void rptCustInfo_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Header)
            {
                Label headertext = new Label();
                headertext = e.Item.FindControl("lblHeaderText") as Label;
                //headertext.Text = custInfo.CustomizationName;
                Label questiontext = new Label();
                questiontext = e.Item.FindControl("lblQuestionText") as Label;
                //questiontext.Text = custInfo.QuestionText;
                //headertext.Text = "";
                //headertext.Text = 
            }
        }

这就是我的回复的创建方式:

public List<CustomizationListCustomization> GetPackageCustomization(string PackageCode)
    {
        List<CustomizationListCustomization> arrCusts = SiteConfiguration.customizationList.Customization.Where(cust => cust.PackageList.Contains(PackageCode)).ToList();

        return arrCusts;
    }

但我找不到任何结果。任何建议我怎样才能实现这一目标? My ObjecT Response

1 个答案:

答案 0 :(得分:0)

 protected void rptCustInfo_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        CustomizationListCustomization custItem = e.Item.DataItem as CustomizationListCustomization;
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            if (custItem != null)
            {
                Label headertext = e.Item.FindControl("lblHeaderText") as Label;
                Label questiontext = e.Item.FindControl("lblQuestionText") as Label;
                Label lblFooter = e.Item.FindControl("lblDisclaimerText") as Label;
                RadioButtonList rdbOptions = e.Item.FindControl("rdbtnOption") as RadioButtonList;

                headertext.Text = custItem.CustomizationName;
                questiontext.Text = custItem.QuestionText;
                lblFooter.Text = custItem.CustomizationDisclaimer;
                ListItem radiolistitem = null;

                if (rdbOptions != null)
                {
                    foreach (var ip in custItem.OptionList)
                    {
                        radiolistitem = new ListItem();
                        radiolistitem.Text = ip.OptionText + " " + ip.OptionPrice.ToString("c");
                        radiolistitem.Value = ip.OptionText;
                        rdbOptions.Items.Add(radiolistitem);
                    }
                }

                //radiolistitem.Attributes.AddAttributes(ip.OptionXML) = custItem.OptionList.Where(p => p.OptionXML != null);

            }
        }
    }