Hai 我正在使用以下代码访问一行中的列,但在使用 Row.Cells[1].Text
时始终显示空字符串我正在 GridView Unload 事件处理程序中使用此代码。
提前谢谢客栈。
foreach (GridViewRow row in grvSearchRingTone.Rows)
{
String coltext = row.Cells[1].Text;
}
最佳答案
我建议改用 Gridview Databound 事件
。因为
Unload event occurs when the server control is unloaded from memory.
protected void GridView1_DataBound(object sender, EventArgs e)
{
foreach (GridViewRow row in grvSearchRingTone.Rows)
{
String coltext = row.Cells[1].Text;
}
}
Databound events occur after the server control binds to a data source.
要了解 gridview 事件的工作原理,请查看 MSDN
关于c# - 通过 Row.Cells 访问 Gridview 列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5959486/