我有一个按钮点击,将从网格视图单元格生成文本。但我想在获得文本时删除href标记。我该怎么做呢?尝试执行.atrributes.remove("href),但无法将其保存到数组列表中
protected void Button_Example_Click(object sender, EventArgs e)
{
foreach (GridViewRow s in GridView_Staff.Rows)
{
CheckBox CheckBox_Staff = (s.FindControl("CheckBox_Staff") as CheckBox);
if (CheckBox_Staff.Checked == true)
{
s.Cells[2].Attributes.Remove("href");
Response.Write("<script>alert('" + s.Cells[2].Text + "');</script>");
}
}
}s.Cells2.Text包含:
<a href="example.com">Example A</a>发布于 2016-07-11 16:48:52
我上次使用webforms和GridView已经有一段时间了,但在我看来,您似乎是在对Cell对象本身调用.Attributes.Remove() (.Cells[2])。但我可能会认为锚定标记在单元格内?
它不是更像这样(请原谅伪代码):
var Anchor = s.Cells[2].FindControl("TheAnchor") as AnchorTag;
Anchor.Attributes.Remove("href");
Response.Write("<script>alert('" + Anchor.Text + "');</script>");或者类似的东西?
https://stackoverflow.com/questions/38302442
复制相似问题