ASP.NET:自定义表错误 [英] ASP.NET: Custom Table Error

查看:73
本文介绍了ASP.NET:自定义表错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误消息是:



找到了具有相同IDtrHop0的多个控件。 FindControl要求控件具有唯一ID。



Error Message is:

Multiple controls with the same ID 'trHop0' were found. FindControl requires that controls have unique IDs.

DataSet ds3 = new DataSet();
ds3 = objOrd.Get_Hop_Period_Data(EmpCode);

for (int k = 0; k < ds3.Tables[0].Rows.Count; k++)
{
    TableRow trHop = new TableRow();
    trHop.ID = "trHop" + k;
    trHop.Height = 25;
    trHop.CssClass = "table";
    trHop.Width = new Unit("100%");
    tblHOPData.Controls.Add(trHop);
    
    int Number = k + 1;
    
    TableCell tcSr = new TableCell();
    tcSr.ID = "tcSr" + k;
    tcSr.CssClass = "label";
    tcSr.Width = new Unit("10%");
    tcSr.HorizontalAlign = HorizontalAlign.Left;
    tcSr.Text = Convert.ToString(Number);
    trHop.Controls.Add(tcSr);
    
    TableCell tcComm = new TableCell();
    tcComm.ID = "tcComm" + k;
    tcComm.CssClass = "label";
    tcComm.Width = new Unit("10%");
    tcComm.HorizontalAlign = HorizontalAlign.Left;
    tcComm.Text = ds3.Tables[0].Rows[k]["COMM_NAME"].ToString();
    trHop.Controls.Add(tcComm);
    
    TableCell tcDesg = new TableCell();
    tcDesg.ID = "tcDesg" + k;
    tcDesg.CssClass = "label";
    tcDesg.Width = new Unit("10%");
    tcDesg.HorizontalAlign = HorizontalAlign.Left;
    tcDesg.Text = ds3.Tables[0].Rows[k]["DESG_NAME"].ToString();
    trHop.Controls.Add(tcDesg);
}

推荐答案

Quote:

找到了具有相同IDtrHop0的多个控件。 FindControl要求控件具有唯一ID。

Multiple controls with the same ID 'trHop0' were found. FindControl requires that controls have unique IDs.

您提供的代码段不会在 FindControl 上发出任何声明。



请检查您尝试查找控件的代码。调试并查看为何找到重复的ID。

The code snippet you have provided does not tell anything on FindControl.

Please check your code where you are trying to find the control. Debug and see why it is finding duplicate IDs.


这篇关于ASP.NET:自定义表错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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