如何在我的网站中解决此错误消息? [英] how solve this error message in my website?

查看:68
本文介绍了如何在我的网站中解决此错误消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是错误信息??



索引(基于零)必须大于或等于零且小于参数列表的大小。 />


我的代码:

 <  < span class =code-leadattribute> script     runat   = 服务器 >  

protected void Page_Load(object sender,EventArgs e)
{
fillpage();
}
private void fillpage()
{
ArrayList comuterlist = connectionclass.getcomputertype(!IsPostBack?%:DropDownList1.SelectedValue);
StringBuilder sb = new StringBuilder();
foreach(计算机列表中的计算机计算机)
{
sb.Append(//此错误
string.Format(
@< class =' computertable' >
< tr >

< th rowspan =' 6' width =' 150px' > < img runat =' 服务器' src =' {6}' > < / th >
< th width =' 50px' > 名称:< / th >
< td > {0} < / td >
< / tr >

< tr >

< th > 类型:< / th >
< td > {1} < / td >
< / tr >
< tr > ;

< th > 处理器:< / th >
< td > {2} < / td >
< / tr >
< tr < span class =c ode-keyword>>


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

< th > 价格:< / 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 >

解决方案

问题在于格式方法占位符({0},{1})。你有6个参数,但编号为0,1,2,3,4,6 !!!

它应该是0到5 !!!

 <   table  >  <   thead  >  <   th     rowspan   =  6    width   =  150px >  <   img     runat   = 'Server'    src   = < b> {6}< / b> >  <   / img  >  < span class =code-keyword><   / th  >  <   / thead  >  <   / table  >  


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:

<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>

解决方案

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!!!

<table><thead><th rowspan="6" width="150px"><img runat="'Server'" src="<b>{6}</b>"></img></th></thead></table>


这篇关于如何在我的网站中解决此错误消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆