At one of Belgrade's finest restaurants last year, Allen Iverson, Carmelo Anthony, LeBron James and many of their youthful U.S. Olympic basketball teammates attended a dinner in their honor. The guests included members of the Serbian national team, all of whom wore matching sport coats.

Iverson and some of his fellow National Basketball Association professionals arrived wearing an assortment of sweat suits, oversize jeans, shimmering diamond earrings and platinum chains, according to NBA officials who were at the dinner.

Larry Brown, the Hall of Fame coach of the U.S. team, was appalled and embarrassed. He later remarked to one official that he had thought about sending some of the worst-dressed players back to the team hotel.

Word of the fashion faux pas eventually made its way to the office of NBA Commissioner David Stern in New York, where concern was already on the rise about how some players were dressing and, more broadly, how the game's appeal was slipping. The NBA had tried mightily to fuse its product with hip-hop culture, viewing its young players and their street fashion sense as a way to connect with a new generation of fans in the post-Michael Jordan era. But that wasn't happening. Indeed, Stern and some of his closest advisers concluded, they might be driving fans away from the sport.

With the new season set to begin Nov. 1, Stern announced a dress code earlier this month that requires players to wear "business casual" attire whenever they are engaged in team or league business. It specifically bans shorts, T-shirts, jerseys, sneakers, flip-flops, headgear such as 'do-rags, and chains, pendants and medallions worn outside clothing.

Stern's image-overhaul decision sparked a contentious debate over fashion and race and called attention to a generational chasm between modern professional athletes, many of whom are black, and their mostly white paying customers.

Recent public opinion polls, as well as some of the NBA's own focus groups, ranked basketball players as the least popular athletes among the major professional sports leagues, according to NBA officials, who spoke on the condition of anonymity. Television ratings for June's NBA Finals plunged 29 percent from the year before.

Asked during a conference call with reporters whether the dress code was aimed at appeasing the NBA's corporate sponsors, Stern replied: "We don't think that looking professional is a corporate decision. Our teams have done it for years, and there was a strong sense that we should do a uniform minimum code across the league, and that's what we did."

Many players who feel their individualism is under siege don't see the issue the same way, and are vowing that they will not allow themselves to be commodified by the league.

"They're targeting my generation -- the hip-hop generation," Iverson said in a television interview. He added, "You can put a murderer in a suit and he's still a murderer." Iverson, along with Denver's Marcus Camby, asked if the NBA would provide players with a clothing stipend to conform to the dress code.

"It's definitely an attack on the hip-hop influence of the NBA," said Elliott Wilson, the editor-in-chief of the hip-hop lifestyle magazine XXL. "It sort of allows the men in charge to think that they have reclaimed the NBA's value system -- and they now have a league that reflects their taste and what they believe in."

The problem is that the relationship between the NBA and hip-hop cuts both ways. The designer sneakers and oversize jerseys and shorts that are now the mainstays of hip-hop fashion appeared first on the basketball court, worn by a generation of players intent on stamping the game with a distinctive new style. For players such as Iverson, who like many stars has a successful clothing line that melds basketball and hip-hop, the dress-code edict could cost money in missed marketing opportunities.

"The style of the players, whether on the court or off, is so intertwined with the style of the streets," said Joseph Anthony, the chief executive of Vital Marketing, an urban youth marketing company. "It's an odd decision for a league that's main draw is the individuality of its players to attempt to create anonymity among its ranks."

Spike Lee, the filmmaker and lifelong fan of the New York Knicks, sees how some could cry hypocrisy -- especially the way the league in recent years marketed players such as Iverson as the next big thing and co-opted hip-hop music in many of its arenas. Moreover, hip-hop stars Jay-Z, Usher and Nelly and are part-owners of NBA franchises.

But "I think David Stern was right on this issue," Lee said in a telephone interview. "What are all those kids wearing the night they're drafted and they shake David Stern's hand? Suits. In corporate America, you have dress codes. Let's be honest: Image is everything. And they're trying to change the image of the league. Between the fight in Detroit last year and other perceptions, they've realized they have a public relations issue. They've set out to change it."

Charles Barkley, the former all-star player and now an analyst for Turner Sports Television, acknowledged there are racial subtexts connected to the new dress code. He also said that's why he's in favor of it.

"Young black kids dress like NBA players," Barkley told the Los Angeles Times. "Unfortunately, they don't get paid like NBA players. So when they go out in the real world, what they wear is held against them. . . .

"If a well-dressed white kid and a black kid wearing a 'do-rag and throwback jersey came to me in a job interview, I'd hire the white kid. That's reality."

The dress code is the most visible component of a broader effort by the league and the National Basketball Players Association to improve the relationship between players and fans. The matter was discussed during collective bargaining this summer, and the players agreed to two more mandated community appearances per season and a directive to sign autographs for fans after leaving the court during warmups.

Stern also announced a new NBA Cares initiative under which the league, its owners and its players would raise and donate $100 million to charities over the next five years. The plan envisions players taking part in coat drives, turkey giveaways and serving food at soup kitchens in November and December.

Stern is viewed as the most proactive and punitive commissioner in U.S. professional sports. His decisions to suspend Latrell Sprewell for an entire season for choking his coach, P.J. Carlesimo, in December 1997, and to suspend Ron Artest of the Indiana Pacers for the rest of the season last year for inciting November's melee between fans and players at the Palace of Auburn Hills in suburban Detroit, were lauded by peers and fans.

But his support of his players also is well documented. Five years ago, Stern publicly admonished an editor of the NBA-sponsored Hoop magazine for airbrushing several of Iverson's tattoos for a cover shoot. The commissioner is fond of criticizing what he says is the media's obsession with covering the negative aspects of the NBA.

The NBA is not unique among professional sports in its concern with its image, though each sport manages the issue in a different way. The National Football League stresses conformity; players can be penalized for removing their helmets on the field and fined for wearing the wrong shade of socks on game day. Some say Major League Baseball's more decentralized structure was partly responsible for allowing the use of steroids and other performance-enhancing drugs by players to spread, but the league has been tackling the problem more aggressively under the threat of congressional sanctions.

NASCAR has moved from a niche, Southern-based sport into the cultural mainstream with a carefully crafted public relations strategy in which it wrapped itself -- and its cars and drivers -- in corporate endorsements.

Stern's possible concern that the NBA's image problems could alienate corporate sponsors and affect future network television contracts may have outweighed his desire for his players to be respected as individuals and accepted by mainstream culture, league officials said. "If you speak to 100 people on the street and most of them think our players are the worst of the lot in pro sports, there's a problem," one official said. "We know the vast majority of our players are good guys."

Mark Cuban, the loquacious owner of the Dallas Mavericks who is fond of wearing Mavericks T-shirts at his team's games, does not understand the fuss over players' appearance. "Some in the NBA want things to work purely in a way they are comfortable with rather than understanding players, communicating with them and understanding how the players can bring added value by dressing to fit the customer, rather than dressing to fit senior management," Cuban said in an e-mail.

"If NBA TV ratings were higher, this never would have come up."

Staff writer Michael Lee contributed to this report.

The fashions worn by NBA players Shaquille O'Neal, left, and Allen Iverson illustrate what is acceptable under the league's new dress code and what is not.Saying "there was a strong sense that we should do a uniform minimum code," NBA Commissioner David Stern, above, instituted rules that mandate what players must wear when engaged in team or league business.The jersey worn by Carmelo Anthony, above left, would be a no-no at NBA events. Above right, Alonzo Mourning shows off acceptable "business casual" attire.