Click here to Skip to main content
15,886,091 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
this is error message??

Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

my code:
XML
<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {
        fillpage();
    }
    private void fillpage()
    {
        ArrayList comuterlist = connectionclass.getcomputertype(!IsPostBack ? "%" : DropDownList1.SelectedValue);
        StringBuilder sb = new StringBuilder();
        foreach (Cpmuter computer in comuterlist)
        {
            sb.Append(   //this error
                string.Format(
              @"<table class='computertable'>
<tr>

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

<tr>

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

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

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

         <th>Price:</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

1 solution

The problem is with the Format method placeholders ({0}, {1}). You have 6 parameters but numbered them as 0,1,2,3,4,6!!!
It should be from 0 to 5!!!
HTML
<table><thead><th rowspan="6" width="150px"><img runat="'Server'" src="<b>{6}</b>"></img></th></thead></table>
 
Share this answer
 
Comments
mhassan083 1-Sep-14 6:19am    
ok good
mhassan083 1-Sep-14 6:19am    
but img does not appear??
Kornfeld Eliyahu Peter 1-Sep-14 6:22am    
Check what the actual src is! And see if it is right!
mhassan083 1-Sep-14 7:05am    
this is for example src which storage in table ..... ../pic/cs2.jpg
but does not appear when run website??!!
Kornfeld Eliyahu Peter 1-Sep-14 7:07am    
It seems that there is no image at ../pic/cs2.jpg...
Check with the browser's debugger from where it tries to download the image and check that place in your server...

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