如何使用动态行id分配htmltablerow tr [英] how to assign htmltablerow tr with the dynamic row id
本文介绍了如何使用动态行id分配htmltablerow tr的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hello frens,
i有这个问题
我想要做的是我有一个字符串,其中包含tr的id名称,我正在尝试使tr显示为true或false,它们在=server运行。
我的代码看起来像这样
Hello frens,
i have this problem
what i want to do is i have a string that holds the name of the id of the tr and i am trying to make that tr visible true or false which are run at ="server".
my code looks like this
if (dr.HasRows)
{
while (dr.Read())
{
string id = "tr" + dr["FieldName"].ToString().Replace(" ", "");
HtmlTableRow tr = pageMain.FindControl(id) as HtmlTableRow;
if (tr != null)
tr.Visible = false;
}
}
但HtmlTableRow tr始终显示空值。请帮助我如何动态地执行此操作
任何帮助将不胜感激。谢谢bishnu
but the HtmlTableRow tr always shows null value . PLease help how can i do that dynamically
any help would be appreciated. thanks bishnu
推荐答案
您好karkiB123,
请查看此解决方案,
为表添加runat =server,如果有任何父标签(panel,div)
Hi karkiB123,
Please check with this solution,
Add runat="server" for table and if any parent tag(panel,div)
if (dr.HasRows)
{
while (dr.Read())
{
string id = "tr" + dr["FieldName"].ToString().Replace(" ", "");
var table = (HtmlTable)tblName.FindControl(id); //tblName ->Table Name
if (table != null)
{
tr.Visible = false;
}
}
}
(发布HTML以获取更多问题)
(Post ur HTML for further issues)
这篇关于如何使用动态行id分配htmltablerow tr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文