This is a migrated thread and some comments may be shown as answers.

ComboBox in the OnItemsRequested error:数组不能为空。
参数名: bytes

0 Answers 53 Views
CheckBox
This is a migrated thread and some comments may be shown as answers.
ghd258 ghd258
Top achievements
Rank 1
ghd258 ghd258 asked on 12 Oct 2017, 09:38 AM
protected override void OnInit(EventArgs e)
        {          
            rcbCustomer.HeaderTemplate = new HeaderTemplate();
            rcbCustomer.ItemTemplate = new HeaderItemTemplate();           
            base.OnInit(e);
        }
 
 public class HeaderTemplate : ITemplate
    {
 
        public void InstantiateIn(Control container)
        {
 
            HtmlTable table = new HtmlTable();
 
            HtmlTableRow row = new HtmlTableRow();
 
            HtmlTableCell cell = new HtmlTableCell();
 
            cell.InnerText = "客户编号";
            cell.Width = Unit.Pixel(100).ToString();
            row.Controls.Add(cell);
 
            HtmlTableCell cell1 = new HtmlTableCell();
 
            cell1.InnerText = "客户名称";
            cell1.Width = Unit.Pixel(160).ToString();
            row.Controls.Add(cell1);
 
            HtmlTableCell cell2 = new HtmlTableCell();
 
            cell2.InnerText = "主联系人";
            cell2.Width = Unit.Pixel(100).ToString();
            row.Controls.Add(cell2);
 
            HtmlTableCell cell3 = new HtmlTableCell();
 
            cell3.InnerText = "类型";
            cell3.Width = Unit.Pixel(100).ToString();
            row.Controls.Add(cell3);
 
            HtmlTableCell cell4 = new HtmlTableCell();
 
            cell4.InnerText = "商务人员";
            cell3.Width = Unit.Pixel(90).ToString();
            row.Controls.Add(cell4);
 
            table.Controls.Add(row);
 
            container.Controls.Add(table);
 
 
        }
 
    }
 
public class HeaderTemplate : ITemplate
    {
 
        public void InstantiateIn(Control container)
        {
 
            HtmlTable table = new HtmlTable();
 
            HtmlTableRow row = new HtmlTableRow();
 
            HtmlTableCell cell = new HtmlTableCell();
 
            cell.InnerText = "客户编号";
            cell.Width = Unit.Pixel(100).ToString();
            row.Controls.Add(cell);
 
            HtmlTableCell cell1 = new HtmlTableCell();
 
            cell1.InnerText = "客户名称";
            cell1.Width = Unit.Pixel(160).ToString();
            row.Controls.Add(cell1);
 
            HtmlTableCell cell2 = new HtmlTableCell();
 
            cell2.InnerText = "主联系人";
            cell2.Width = Unit.Pixel(100).ToString();
            row.Controls.Add(cell2);
 
            HtmlTableCell cell3 = new HtmlTableCell();
 
            cell3.InnerText = "类型";
            cell3.Width = Unit.Pixel(100).ToString();
            row.Controls.Add(cell3);
 
            HtmlTableCell cell4 = new HtmlTableCell();
 
            cell4.InnerText = "商务人员";
            cell3.Width = Unit.Pixel(90).ToString();
            row.Controls.Add(cell4);
 
            table.Controls.Add(row);
 
            container.Controls.Add(table);
 
 
        }
 
    }
 
 
<telerik:RadComboBox ID="rcbCustomer" runat="server" Width="100%" AllowCustomText="true"
                            Text="" OnClientItemsRequesting="ClientCustomerItemRequesting" HighlightTemplatedItems="true"
                            DropDownWidth="550px" ExpandAnimation-Duration="100" CollapseAnimation-Duration="100"
                            OnClientSelectedIndexChanged="OnClientSelectedIndexChangedCustomer" EnableLoadOnDemand="true"
                            AutoPostBack="true" OnItemsRequested="rcbCustomer_ItemsRequested" Height="200px">
                            <HeaderTemplate>
                                <ul class="Item">
                                    <li class="col2">客户名称</li>
                                    <li class="col3">主联系人</li>
                                    <li class="col4">客户类型</li>
                                </ul>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <ul class="Item">
                                    <li class="col2">
                                        <%# Healthway.Framework.Utilities.String.StringHelper.InternalHtmlEncode(DataBinder.Eval(Container, "Attributes[\"CusName\"]").ToString())%>
                                    </li>
                                    <li class="col3">
                                        <%# Healthway.Framework.Utilities.String.StringHelper.InternalHtmlEncode(DataBinder.Eval(Container, "Attributes[\"LinkmanName\"]").ToString())%>
                                    </li>
                                    <li class="col4">
                                        <%# Healthway.Framework.Utilities.String.StringHelper.InternalHtmlEncode(DataBinder.Eval(Container, "Attributes[\"CusTypeName\"]").ToString())%>
                                    </li>
                                </ul>
                            </ItemTemplate>
                            <FooterTemplate>
                                <div>
                                    <b>更多请输入助记码查询.</b>
                                </div>
                            </FooterTemplate>
                        </telerik:RadComboBox>
 
    Customer cus = new Customer();
                cus.CusName = "全部";
                cus.CustomerID = -1;
                cus.LinkmanName = string.Empty;
                cus.CusCode = string.Empty;
                cus.CusTypeName = string.Empty;
                cus.SaleManName = string.Empty;
                list.Insert(0, cus);
                foreach (Customer customer in list)
                {
                    RadComboBoxItem item = new RadComboBoxItem();
                    item.Value = customer.CustomerID.ToString();
                    if (isSupplier == 1)
                    {
                        item.Text = customer.CusName;
                    }
                    else
                    {
                        item.Text = customer.LinkmanName;
                    }
                    item.Attributes.Add("CusCode", customer.CusCode);
                    if (isSupplier == 1)
                    {
 
                        item.Attributes.Add("CusName", customer.CusName);
                    }
                    else
                    {
 
                        item.Attributes.Add("CusName", customer.LinkmanName);
                    }
                    item.Attributes.Add("LinkmanName", customer.LinkmanName);
                    item.Attributes.Add("CusTypeName", customer.CusTypeName);
                    item.Attributes.Add("LinkmanMobile", customer.LinkmanMobile);
                    if (customer.SaleManName == null)
                    {
                        item.Attributes.Add("SaleManName", "");
                    }
                    else
                    {
                        item.Attributes.Add("SaleManName", customer.SaleManName);
                    }
                    comboBox.Items.Add(item);
                }
                comboBox.DataBind();

No answers yet. Maybe you can help?

Tags
CheckBox
Asked by
ghd258 ghd258
Top achievements
Rank 1
Share this question
or