Speaking for my own environment, the Netherlands, I can say with some certitude that the city-canals were definitely a victim to better road works. A great many Dutch cities have streets that are former canals, filled up in the late 19th or early 20th century. No effective railways could obviously be set-up in such a small environment as a city center.
If you're talking about longer canals for transport between regions, the matter becomes a lot more complicated. Considering your tag, I kind of assume you're asking this in the light of a UK context, which is probably its own kettle of fish. Again, given your tag I'd assume you know a lot more about this than I do.
Regardless, in the early 20th century, even though road transport began to pick up, transport by rail was still much more efficient for longer hauls, exactly the kind of thing canals were built for. Large loads transported to a general location. Use smaller means to distribute from there.
I would be highly surprised if one could not chalk the 'canal death' in the UK up to the railways.
In contrast, the canals in my own country did not nearly lose as much importance. Water transport is still a massive thing in the Netherlands, given our location and access to rivers, especially the Rhine leading into the European hinterland. Whilst even modern rail is obviously a much faster method of transport, the capacity of a modern canal suited for large freshwater transports is practically unrivalled. Which continues to make it a staple of economic infrastructure in some European countries.
Sorry if I misunderstood the question. I would've half expected someone with your flair to answer this instead of ask, so it makes me think you're looking for a real deep and specific answer.