In the episodes `` In the Shadow of Two Gunmen '' and `` Bartlet for America '' , flashbacks are used to tell how Bartlet defeated Texas Senator John Hoynes ( Tim Matheson ) and Washington Senator William Wiley for the Democratic nomination .
In the episodes `` In the Shadow of Two Gunmen , Part I '' , `` In the Shadow of Two Gunmen , Part II '' and `` Bartlet for America '' , flashbacks are used to tell how Bartlet defeated Texas Senator John Hoynes ( Tim Matheson ) and Washington Senator William Wiley for the Democratic nomination .