Click here to Skip to main content
15,880,469 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
my code in explorer debugger(F12) :
XML
<tr>

         <th rowspan='5' width='150px'><img runat='Server' src='../pic/cs1.jpg'></th>
         <th width='50px'>Name:</td>
         <td>laptop</td>
</tr>





this is my real code :

XML
private void fillpage()
    {

        ArrayList comuterlist = connectionclass.getcomputertype(!IsPostBack ? "%" : DropDownList1.SelectedValue);
        StringBuilder sb = new StringBuilder();
        foreach (Cpmuter computer in comuterlist)
        {
            sb.Append(
                string.Format(
              @"<table class='computertable'>
<tr>

         <th rowspan='5' width='150px'><img runat='Server' src='{5}'></th>
         <th width='50px'>Name:</td>
         <td>{0}</td>
</tr>

<tr>

         <th>Price:</th>
         <td>{1}</td>
</tr>
<tr>

         <th>Processor:</th>
         <td>{2}</td>
</tr>
<tr>

         <th>Ram:</th>
         <td>{3}</td>
</tr>
<tr>

         <th>Type:</th>
         <td>{4}</td>
</tr>

 </table>",
         computer.name, computer.price, computer.processor, computer.ram, computer.type, computer.image));
            lblout.Text = sb.ToString();
        }
    }

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        fillpage();
    }
</script>
Posted

Add the id attribute to your img like this


Server side you can access it through its id
Also, don't concatenate table(s) in the code, use asp:Repeater and put your templated header and row into its placeholders and then fill the data in suitable events (RowDataBound or whatever you need). You can even do this in the template and it will be filled with DataSource data:
]]>


Google asp:Repeater[^]
 
Share this answer
 
Comments
mhassan083 3-Sep-14 6:43am    
does not display image?!!
mhassan083 3-Sep-14 10:03am    
this is a true url ".../empty-image.jpg"
... or ..??????
Sinisa Hajnal 3-Sep-14 15:06pm    
No, that is a placeholder, of course it will not display the image if you don't have one such. that was an example. Just like you will not name it my-image, but give it some sensible name within your system.

I mean, you can see it is not real URL since its local to your site...
Please make This Changes And Try...
<img id="my-image" runat="server" src="~/empty-image.jpg" />

..
Put A Tilt(~)..
Thanks..
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900