private void Repeater7_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
{
BindCtrl(string,1,2,3,e);
}
public void BindCtrl(string 传入值1,传入值2,传入值3,System.Web.UI.WebControls.RepeaterItemEventArgs e)
{
HyperLink link7=(HyperLink)e.Item.FindControl("传入值1");
string t7=(string)DataBinder.Eval(e.Item.DataItem,"传入值2");
t7=t7.Substring(0,传入值3);
link7.Text=t7;
}

解决方案 »

  1.   

    错误行link7.Text=t7;
    System.NullReferenceException: 未将对象引用设置到对象的实例
      

  2.   

    刚才值写错了,t7=t7.Substring(0,传入值);
    提示错误
    System.ArgumentOutOfRangeException: 索引和长度必须引用该字符串内的位置。参数名: length
      

  3.   

    你的t7的长度必须大于你传入的值
    if (t7.Lenght > 传入值) t7 = t7.Substring(0,传入值)