首页 > 代码库 > 模板列解决一行多列表间关联

模板列解决一行多列表间关联

前台页面    

        </f:TemplateField>
                    <f:TemplateField HeaderText="普通巡检频次" Width="60px">
                        <ItemTemplate>
                            <asp:Label ID="Label2" runat="server" Text=‘<%# GetFrequency(Eval("freq")) %>‘></asp:Label>
                        </ItemTemplate>  

              </f:TemplateField>

后台       

    private Area[] arr;        

    private void LoadData()        

    {            

      arr = DB.Areas.ToArray();           //数据准备 

       // 每页记录数            

    Grid1.PageSize = ConfigHelper.PageSize;            

    ddlGridPageSize.SelectedValue = http://www.mamicode.com/ConfigHelper.PageSize.ToString();

            BindGrid();

        }

 

        protected string GetFrequency(object freq)        

    {             string tmpStr = "";

              var  tmpInt = Convert.ToInt32(freq);            

      foreach (var a in arr)            

      {                

         if (a.ID == tmpInt)                

        {                    

           tmpStr =  a.Name;                    

           break;                

        }            

      }            

     return tmpStr;       

  }

模板列解决一行多列表间关联