找到按钮单击时动态创建的所有链接按钮 [英] Find all linkbuttons that are dynamically created on button click
本文介绍了找到按钮单击时动态创建的所有链接按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个表,我使用c#动态填充它。在每一行中,我都有一个带有特定ID的链接按钮。该ID如下EDIT#+ data.rows [index] [ID]。当我点击一个按钮然后启用它时,如何找到所有这些链接按钮= false
这是我认为可以使用的代码。但是,它甚至没有在调试中使用此代码
I have a table and i populate it dynamically using c#. In each row i have a link button with a specific ID. This ID is as follows "EDIT#" + data.rows[index]["ID"]. How can I find all these linkbuttons when i click a button and then just make it enabled=false
Here is the code i have which i thought would work. However, it doesnt even go into this code on debug
int row = 0;
foreach (var button in callData.Rows[row].Controls.OfType<LinkButton>())
{
button.Enabled = false;
row = row++;
}
请指点我的方向。
Please point me in the direction.
推荐答案
最简单的方法是创建LinkButtons
的地方。仅在那个地方,设置linkButtonId.Enabled = false;
。
The easiest way would be the place where you are creating theLinkButtons
. At that place only, setlinkButtonId.Enabled = false;
.
foreach(var row in callData.Rows)
{
foreach (var button in row.Controls.OfType<LinkButton>())
{
button.Enabled = false;
}
}
我终于解决了这个问题。随着更多的谷歌搜索和F-ES Stercore给出的代码,我可以完成剩下的代码。
对于那些感兴趣的人,这是我的意思确实
I have finally solved this issue. With many more google searches and the code F-ES Stercore gave, I could get the rest of the code done.
For those who are interested, here is what i did
foreach (HtmlTableRow row in callData.Rows)
{
foreach (HtmlTableCell cell in row.Cells)
{
foreach (var linkbtn in cell.Controls.OfType<linkbutton>())
{
if (linkbtn.Text == "Edit")
{
linkbtn.Visible = false;
}
}
}
}
</linkbutton>
这篇关于找到按钮单击时动态创建的所有链接按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文