Label显示绑定dropdownlist数据~

  < ItemTemplate >
            
< asp:Label  ID ="Label1"  runat ="server"  Text =<%#  GetReportsToName(Eval("ReportsTo")) % >  />
         
</ ItemTemplate >
         
< EditItemTemplate >
            
< asp:DropDownList  ID ="DropDownList1"  runat ="server"  DataSourceID ="ReportsToList"
               DataTextField
="Name"  DataValueField ="EmployeeID"  SelectedValue ='<%#  Bind("ReportsTo") % > '
               Width="157px">
            
</ asp:DropDownList >
         
</ EditItemTemplate >

   public string GetReportsToName(object reportsToId)
   {
      foreach (DataRowView row in ReportsToList.Select(DataSourceSelectArguments.Empty))
      {
         if (reportsToId.Equals(row["EmployeeID"]))
         {
            return row["Name"].ToString();
         }
      }
      throw new ArgumentException("Employee with ID: "
         + reportsToId.ToString() + " does not exist.");
   }

你可能感兴趣的:(label)