President Donald Trump should not declare a national emergency over illegal immigration in order to bypass Congress to get his long-promised wall along the U.S.-Mexico border, Sen. Chuck Grassley, a veteran Republican from Iowa, told CNBC on Friday.

Declaring a national emergency could give the president the ability to use the military to build the wall instead of getting Congress to approve funding for it.

Trump wants about $5.7 billion for border security, including about 234 miles of new barriers. Democrats, who now control the House, have refused to allocate any money that goes to the building of any more walls or fences along the U.S. southern border.

Grassley said in a "Squawk Box" interview that "I believe you're going to find it in the courts almost immediately. And the courts are going to make a decision" if Trump declares an emergency. Grassley said the quicker the Supreme Court could make a decision on the matter should it come to pass the better.

"The president is threatening emergency action, a national emergency declaration. I don't think he should do that. I think it's a bad precedent. And it contravenes the power of the purse that comes from the elected representatives of the people," said Grassley, who was elected to Congress in 1974 and the Senate in 1980.

On Wednesday, Trump said he will "probably" declare a national emergency if a wall deal can't be worked out.

Sen. Marco Rubio, who unsuccessfully sought the 2016 GOP presidential nomination said Wednesday on CNBC that a national emergency declaration by Trump could create a slippery slope.

"If today, the national emergency is border security ... tomorrow the national emergency might be climate change," said the Florida lawmaker, referring to climate change as an issue that's near and dear to Democrats and anathema to Republicans.

Both Trump and Democrats have been digging in on their wall positions, leading to a partial government shutdown, now in Day 21. On Friday, the shutdown tied the 1995-96 closure during the Clinton administration as the longest ever. Also Friday, more than 800,000 federal workers were starting to miss paychecks.

Grassley, who once again takes on the chairmanship of the Senate Finance Committee, said, "I don't understand why there can't be a compromise here." He added, "We have so many senators and a lot of House members that have already supported 650 miles of fence" in the past.

As recently as 2013, Senate Democrats supported immigration legislation that called for border fencing to be built. That bill was stopped in the then-GOP controlled House. Democrats nowadays said the conditions were different then.

"Then you have Republicans supporting something that Democrats want to do, something about the DACA kids. Seems like there's plenty of opportunity here to compromise," Grassely said.

In negotiations with Trump to end the current shutdown, Democrats had agreed to some border wall funding as part of an ultimately scuttled deal to protect the so-called Dreamers, people who were illegally brought to the U.S. as children.

"You got to negotiate is the bottom line," said Grassely, who has spent more than four decades on Capitol Hill.

On the other side, House Majority Leader Steny Hoyer certainly agreed with Grassley that a deal needs to be made. But Hoyer, a Democrat from Maryland, told CNBC in a separate appearance Friday that Trump's proposed wall is not immoral, as many of his Democratic colleagues have called it. But he said it would be ineffective and a waste of money.

The border wall is "not a question of morality," said the Maryland Democrat. "For me, it's a practical issue. Is it effective? Will it work? Is it the best thing we can do to secure the border? Most of the people I talk to, including on the border, don't think it is."

WATCH: Hoyer says the government shutdown is 'immoral'