Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Paypal Button HTML in datagrid column

Status
Not open for further replies.

jaycast

Programmer
Nov 28, 2001
42
0
0
US
I'm trying to populate a datagrid column with the paypal buy now button HTML that I am storing in my database. My goal is to have a table with merchandise information and a column that holds all HTML for the individual buy now buttons. Granted, this might not be the best way to do this, but I'm muddling through.

How can I go about generating the following sample dynamically from a database to a datagrid?

Code:
<form action="[URL unfurl="true"]https://www.paypal.com/cgi-bin/webscr"[/URL] method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="image" src="[URL unfurl="true"]https://www.paypal.com/en_US/i/btn/x-click-but23.gif"[/URL] border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIH... lots of characters...FaWCmOBKg==-----END PKCS7-----
">
</form>
 
I have done this before.
You can't put forms inside of forms, but this will work.

Code:
<form runat=server id=form1>
<asp:datagrid runat=server id=datagrid1>

<Columns>
<asp:TemplateColumn  HeaderText="Click to Buy">
						<ItemTemplate>
							<a href='#' onclick='<%# "PostForm(""" & DataBinder.Eval(Container.DataItem,"MyEcryptedPayPalValue") & """)"%>;return false;' ><img src="[URL unfurl="true"]https://www.paypal.com/en_US/i/btn/x-click-but23.gif"[/URL] border=0 /></a>
						</ItemTemplate>
					</asp:TemplateColumn>

</Columns>

</asp:datagrid>



<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" id="encrypted" name="encrypted" value="" />
</form>

<script language="javascript">
		function PostForm(value){

document.getElementById("encrypted").value=value

			var pp="[URL unfurl="true"]https://www.paypal.com/cgi-bin/webscr"[/URL]
			document.forms[0].action=pp
			document.forms[0].submit()
			return false
			
		}
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top