指数超出范围。必须是非负数且小于collection.Parameter name:index的大小 [英] Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index

查看:111
本文介绍了指数超出范围。必须是非负数且小于collection.Parameter name:index的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
可以帮我解决这个问题吗?将数据绑定到下拉列表。





html代码

hi can any one help me to solve this? am binding data to dropdownlist.


html code

<telerik:RadComboBox ID="cmbEPS" runat="server" Height="22px" Width="200px">
                                    <ItemTemplate>
                                        <div onclick="StopPropagation(event)">
                                            <asp:TreeView ID="tvWBS" runat="server" NodeStyle-NodeSpacing="2px"

                                                ShowLines="true">
                                                <HoverNodeStyle CssClass="CustomNodeColor" />
                                                <SelectedNodeStyle BackColor="#5B5B5B" ForeColor="White" HorizontalPadding="3px" />
                                                <NodeStyle ForeColor="#000000" />
                                            </asp:TreeView>
                                        </div>
                                    </ItemTemplate>
                                </telerik:RadComboBox>
                                <asp:RequiredFieldValidator ID="rfvActivityGroup" runat="server" ControlToValidate="cmbActivityGroup"

                                    Display="None" ErrorMessage="Select EPS" SetFocusOnError="True" ValidationGroup="g"

                                    Visible="true"></asp:RequiredFieldValidator>









.................... .................................................. .................................................. .................................................. ................................
in .cs







.......................................................................................................................................................................................................
in .cs

RadComboBox cmbEPS = (RadComboBox)phDynamic.FindControl("cmbEPS");
       if (cmbEPS !=null)
       {

               RadTreeView rtvEPS = (RadTreeView)cmbEPS.Items[0].FindControl("rtvEPS");//in this line am getting error..





谢谢



thank you

推荐答案

使用索引的该指令的唯一部分是Items集合。这意味着没有可供选择的项目。

在检查空控件时以及访问之前检查集合的大小。
The only part of that instruction using an index is the Items collection. Which implies there are no Items to select from.
Check the size of the collection when you check for a null control, and before you access it.


这篇关于指数超出范围。必须是非负数且小于collection.Parameter name:index的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆