日期:2011-12-17  浏览次数:20441 次

页面关键代码:绑定一个方法
                                <asp:TemplateColumn HeaderText="编号">
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                        <ItemTemplate>
                        <%# getindex(DataBinder.Eval(Container.DataItem, "id"))%>
                        </ItemTemplate>
                    </asp:TemplateColumn>

后台处理此方法:
        public int getindex (Object deptcode)
        {
            int ri=0;
            DataView mydv=new depart().depart_getalldept();
            for (int i=0;i<mydv.Count;i++)
            {
                if (mydv[i].Row["bmid"].ToString()==deptcode.ToString())
                {
                    ri=i;
                    i=mydv.Count;
                }
            }
            return ri;
        }