我的代码如下
((LinkButton)GridView1.Rows[0].Cells[0].Controls[0]).Text = "INSERT";
Run Code Online (Sandbox Code Playgroud)
我得到了错误
无法将"System.Web.UI.WebControls.TextBox"类型的对象强制转换为"System.Web.UI.WebControls.LinkButton"类型
嗯......问题似乎是GridView1.Rows [0] .Cells [0] .Controls [0]是类的对象TextBox而不是LinkButton.您应该修复gridview内容.