Click here to Skip to main content
14,579,459 members
Rate this:
Please Sign up or sign in to vote.
See more:
int i;

       title = "";
       for (i = 0; i < ds.Tables[0].Rows.Count; i++)

       {

           title = title + "<div class='one' ><div class='Solar Mobile'><h1>" + (i + 1).ToString() + "." + ds.Tables[0].Rows[i]["product_name"].ToString() + " Just Rs." + ds.Tables[0].Rows[i]["price"].ToString() + "/-<asp:ImageButton ID='ImageButton1' runat='server' ImageUrl='~/images/cart.jpg' onclick='Addtocart' /></h1></div><div class='Solar-text' >" + ds.Tables[0].Rows[i]["description"].ToString() + "</div ><div class='img'><img  src='imggrab.aspx?ID=" + ds.Tables[0].Rows[i]["pk_product_id"].ToString() + "' /></div><div class='clr'></div></div>";
       }


is it correct ... i'm trying to call
Addtocart
function but the asp image button does not appers... why so...?
thanks in advance
Posted
Rate this:
Please Sign up or sign in to vote.

Solution 1

Injecting HTML to the page is alright, but you can't inject an asp.net control as inline html.

Instead try to add controls to the parent control.
   
Comments
devildx2050 8-Oct-11 3:11am
   
so what is the alternate solution of this problem ??
Rate this:
Please Sign up or sign in to vote.

Solution 2

It doesn't work. you can render the html using Rosponse.Write method, but cannot render server controls (asp:ImageButton). I think here you are trying to add the item to a cart. Please add a GridView control and bind the data from table directly and try to customize the grid. You can do all these style things in GridView template columns.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100